Harlequins will take a nine-point lead to the Galway Sportsground for the second leg of the Parker Pen Challenge Cup semi-final on 25 April.
PARKER PEN CHALLENGE CUP
Harlequins (11) 31
Tries: Deane, Harder, Monye, Greenwood
Pens: Burke 2
Connacht (10) 22
Pens: McHugh, Elwood 4
The 2001 winners outscored Connacht by four tries to one in the first leg at the Stoop but saw their lead whittled away by a string of penalties.
Mel Deane scored the first try for the home side but Connacht replied before half-time with Matt Lacey's touchdown.
George Harder, Will Greenwood and Ugo Monye got second-half tries for Quins.
After an early exchange of penalties between Connacht's Mark McHugh and Paul Burke of Harlequins,
Burke landed a drop to edge the home side ahead.
Quins then took control of the contest, opening an 11-3 lead when former Connacht player Deane went over in the left corner on 17 minutes.
With McHugh and Eric Elwood missing penalties for the visitors, things seemed to be going the way of the English side.
But in first-half stoppage time, Lacey got Connacht's touchdown and Elwood converted to leave it 11-10 at the break.
Quins put in a strong display in the second half, with wingers Harder and Monye supplying fine finishes.
But Elwood was in fine kicking form for Connacht, landing a succession of penalties as the Irish province moved to within four points going into the last few minutes.
England centre Greenwood then stretched Quins' lead again, grabbing a vital fourth try near the end.
Quins coach Mark Evans said they should go to Galway on 25 April aiming to win the second leg.
"Connacht are a very good side and I do not think they have got the credit they deserve," said Evans.
"I think we need to go there and win - and we should be capable of that."
Connacht coach Michael Bradley said he was relieved to be just nine points in arrears.
"If you come away from a match having been outscored by four tries
to one and are only nine points behind you have to be happy," said Bradley.
"It will be tied up nicely to get the Connacht crowd behind us and win by 10 points."
Harlequins: Duffy, Harder, Greenwood, Deane, Monye, Burke, Keogh, Worsley, Fuga, Dawson, Miall, Evans, Winters, Vos, Diprose. Replacements: Hayter, Gomez, Jones, Davison, Sheriff, Willis, Dunne.
Connacht: Mostyn, McPhillips, Yapp, McHugh, Munn, Elwood, Walls, McFarland, Jackman, Clarke, Browne, Farley, Swift, Lacey, O'Sullivan. Replacements: Fogarty, Bracken, McCarthy, Neville, O'Loughlin, Moore, Robinson.
Referee: Nigel Whitehouse (Wales).