Connacht, making their Heineken Cup debut, pushed Harlequins all the way as the Aviva Premiership leaders just about hung on to this season's 100 per cent record.
The Irish side scored two tries to one but an 20-point goal-kicking display from fly-half Nick Evans narrowly edged Quins to their 11th successive victory of the campaign.
Scrum-half Karl Dickson scored Quins' only try as they set a club record best start to a season, overtaking their 10 wins in both the 1954-55 and 1996-97 seasons.
Connacht replied with tries from left-wing Tiernan O'Halloran and their former Harlequins full-back Gavin Duffy. Fly-half Miah Nikora landed a penalty and conversion before his replacement Niall O'Connor contributed a penalty.
Duffy, who made 92 appearances for Quins between 1993 and 1995, gifted his old club their opening score after only four minutes when he hung on to the ball in the tackle, leaving Evans an easy penalty.
Nikora and Evans exchanged further penalties inside the opening 10 minutes before the Irish side scored the first try.
Quins handed Connacht the initiative, conceding a free-kick at a scrum and a spell of intense pressure produced a slick handling move which ended with centre Eoin Griffin sending O'Halloran clear, with Nikora converting.
Evans' third penalty cut the deficit to one point as the sides served up a full-blooded European tie.
Harlequins possessed the more forceful runners with their powerful forwards, orchestrated by former All Black Evans, posing a real threat to the visiting defence.
But, following a series of forward drives, it was Dickson who burrowed in for the try which put Quins ahead, justifying rugby director Conor O'Shea's decision to keep faith with him ahead of England scrum-half Danny Care.
Evans' conversion stretched his side's lead to 19-10 before the interval with his fourth penalty of the half after Connacht's replacement flanker TJ Anderson's high tackle on opposite number Robshaw.
When the visitors released their fast-moving threequarters they looked dangerous but they had been guilty of kicking too much possession away in the first half.
They changed their tactics in the second half and posed a much more serious threat as they ran the ball.
Duffy and right-wing Brian Tuohy combined to stretch Quins before the English side, tackling ferociously, turned the ball over to return to the attack.
Harlequins were denied a second try when referee Jerome Garces ruled the Connacht defence had been obstructed as Marler crashed over following a lineout.
Duffy's excellent kick to the corner put Harlequins under pressure when their winger Sam Smith was forced into touch by the corner flag.
Winning the resulting lineout, Connacht quickly moved the ball from right to left before the slick passing of O'Connor and Griffin put Duffy over for their second try, converted by O'Connor to cut the margin to two points.
Quins were hanging on perilously but Evans eased their worries with his fifth penalty in the 75th minute.
His sixth, two minutes from time, cruelly denied Connacht the consolation of a losing bonus points, which was the least they deserved after a display that will give them plenty of confidence.