Harlequins' hopes of becoming the first team to reach the Heineken Cup last eight having lost their first two pool matches were dealt a fatal blow by Pool Four leaders Clermont Auvergne.
A Brock James penalty was poor reward for Clermont's impressive opening.
Quins hit back with a Matt Hopper try, and a conversion and two penalties from Nick Evans to lead 13-3 at the break.
But Napolioni Nalaga and Sitiveni Sivivatu tries levelled matters before James's late penalty secured victory.
It was a fine game which finished in dramatic fashion as Clermont fought back to first make sure of a losing bonus point and then a draw, before James slotted a 76th-minute penalty to secure victory and with it the group.
Even then Quins could have snatched victory, but a late line-out went astray and although they won the resulting scrum against the head, Nick Easter was held up five metres out and turned over to finally extinguish their hopes - bar a series of very unlikely results - of reaching the last eight.
Clermont, last season's beaten finalists, looked as though they would blow Quins away in the opening quarter but thanks to some dogged defence - especially at the breakdown - and several errors from the visitors, the Londoners held out and then took control of the first half.
Clermont are considered by many observers to be as potent an attacking side as there is in Europe and they looked every inch of that boast in a dazzling first 20 minutes - bar an inability to hold onto the ball with the try-line in sight.
When the French club, who had taken the lead through a James penalty, butchered Quins at the first scrum it looked ominous for the hosts and Clermont then twice should have scored the first try of the game.
First, after Fritz Lee's 30m break from the base of a scrum, Nalaga dropped a pin-point James cross-kick with the line at his mercy.
And a minute later James again opened up the home defence, but Samoan number eight Lee spilled his pass 10m out with a clear run to the line.
They were two massive let-offs for the Londoners and they took full advantage, with livewire scrum-half Danny Care sparking Quins into life.
The England nine took a quick tap penalty and was on hand to collect Chris Robshaw's chip ahead before producing a dazzling reverse pass inches before going into touch to the supporting Hopper, who cantered over untouched.
Evans had missed an earlier shot at goal but he converted and landed two penalties to make it 13-3 at the break.
Despite struggling on occasion in both the scrum and line-out, Quins had looked increasingly threatening, with Clermont growing ragged as their early confidence ebbed away, but the French side were a different proposition after the break.
Once again they started better and hit back when France scrum-half Morgan Parra chipped ahead, the ball turned right on the bounce to wrong-foot full-back Mike Brown and Nalaga kicked ahead to score.
James missed the conversion but suddenly there were only five points in it with Clermont attacking in waves.
Quins' hopes were not helped as they lost Charlie Walker and Care - whose ankle injury may affect his Six Nations participation - inside five minutes, with Ollie Lindsay-Hague and Karl Dickson entering the fray.
But they managed to resist the Clermont onslaught and could have gone eight points ahead - a wining margin that would have put them top of the group - with 10 minutes to play, but Evans pulled a kickable penalty wide.
That seemed to deflate the hosts and lift Clermont, and within two minutes former All Black Sivivatu finished off an irresistible attack with a try in the corner to level the scores.
James's missed conversion kept Quins in the hunt but four minutes from time he made no mistake with a penalty and although Quins launched one last assault, they could not storm the Clermont barricades.
Harlequins director of rugby Conor O'Shea: "We didn't start particularly well but then a piece of absolute genius from Danny Care changes the energy our way and we were pretty much on top for the rest of the first half.
"Danny's piece of skill was quite exceptional. You can't practice that. He gave us a bit of momentum and he's a game changer.
"Mike Brown had covered the ball [for their opening try] and it bounced badly. You can't blame anyone when that happens."
Harlequins: Brown; Walker, Hopper, Molenaar, Monye; Evans, Care; Marler, Ward, Collier, Kennedy, Robson, Wallace, Robshaw, Easter.
Replacements: Lindsay-Hague for Walker (46), Dickson for Care (49), Matthews for Kennedy (55), Guest for Wallace (61).
Not Used: Gray, Lambert, Doran-Jones, Botica.
Clermont Auvergne: Buttin; Sivivatu, Rougerie, Fofana, Nalaga; James, Parra, Domingo, Kayser, Zirakashvili, Cudmore, Hines, Bardy, Lapandry, Lee.
Replacements: Stanley for Rougerie (66), Debaty for Domingo (57), Paulo for Kayser (55), Ric for Zirakashvili (67), Pierre for Hines (70).
Not Used: Vosloo, Radosavljevic, Delany, Granouillet.
Ref: John Lacey (Ireland).