Harlequins missed a great opportunity to clinch a place in the quarter-finals of the Heineken Cup as they fell to a shock defeat by Connacht.
Victory in Galway would have been enough for Conor O'Shea's Quins because leaders Toulouse were beaten by Gloucester.
Harlequins winger Sam Smith squeezed over for an early try but three Niall O'Connor penalties put Connacht ahead.
Quins' defeat in Pool 6 also guarantees Ulster's passage from Pool 4.
Brian McLaughlin's men face a tough match away to Clermont Auvergne on Saturday but now know their quarter-final place is assured, as even defeat will leave them with a best runners-up spot berth.
For Connacht, it was a first win since 23 September. They had lost their last 14, including all five in their debut Heineken Cup season.
Eric Elwood's western province were in front for most of a match played in difficult stormy conditions in Galway.
Harlequins had got a dream start when they moved the ball left and a long pass from Nick Evans allowed winger Smith to get the eighth-minute touchdown in the corner.
Connacht, though, with a strong wind in their favour, established a four-point lead thanks to three well-judged penalties by former Ulster fly-half O'Connor.
The Irish province piled on sustained pressure late in the first half and were close to the Harlequins line when the visitors conceded a penalty for not rolling away.
Connacht opted to kick the points - only for O'Connor to fluff the easiest of his four place kicks.
At just four points down, Quins must have fancied their chances of overhauling the deficit with the conditions in their favour for the second half.
An Evans penalty on the hour left them just one point in arrears but the fly-half missed with another attempt which would have given Harlequins the lead.
Quins pressed for another score but Connacht deservedly held on to celebrate at the final whistle.
Harlequins captain Chris Robshaw: "Playing into the wind, you always have to play a bit more with the ball and to only go down by four points at half-time, it was kind of ideal so to speak.
"We came out buzzing, got our feet on the ground, got a bit of momentum going but unfortunately we couldn't finish it off. It's hard to put into words how disappointed we are, it's a very low point.
"We're going to have to hope that someone else slips up along the line. It probably doesn't look like (we'll qualify).
"No-one was complacent. We wanted to be in the knockout stages. We didn't just want to be there to make up the numbers - we came in here to give it a real go.
"Obviously we'll see where things end up on Sunday night, but in all honesty we probably will be back in the Amlin (defending the title we won last year)."
Connacht coach Eric Elwood: "Even with the last scrum with nine seconds left I still wasn't convinced until the ref had blown the whistle and the ball was off the park, and people were invading the pitch.
"Unfortunately in Connacht we don't make things easy, but I have to acknowledge the commitment of the boys.
"I think everyone got their reward tonight - the players and the crowd, and it was not the prettiest of games - but we have been knocking on the door for the last 13 weeks so I am quite happy to take an ugly win, no problem.
"What it means is that we have the monkey off our backs. The lads now know that against one of the better teams of Europe we can grind out a victory if we need to, but to do that you have to do the simple things right."
Connacht: Duffy, Vainikolo, Tonetti, Fa'afili, O'Halloran, N O'Connor, O'Donohoe, Wilkinson, Flavin, Loughney, Swift, McCarthy, Muldoon, Ofisa, Naoupu.
Replacements: Reynecke for Flavin (59), Rogers for Loughney (77).
Not used: Buckley, Kearney, McKeown, Moore, Nikora, Jarvis.
Harlequins: Brown, Monye, Hopper, Turner-Hall, S Smith, Evans, Care, Marler, Brooker, Johnston, Vallejos, Robson, Fa'asavalu, Robshaw, Easter.
Replacements: Casson for Turner-Hall (79), Lambert for Marler (72), Gray for Brooker (61), Kohn for Vallejos (48), Wallace for Fa'asavalu (41).
Not used: Fairbrother, Bolt, Clegg.
Referee: Nigel Owens (Wales)