Marcus Smith missed a late conversion as Harlequins were knocked out of the Heineken Champions Cup by Montpellier, losing by a single point on aggregate.
The English champions, who were beaten 40-26 in France, raced into an early lead through Huw Jones.
Alex Dombrandt, Joe Marchant and Louis Lynagh also crossed in the first half.
Yvan Reilhac and Julien Tisseron scored for Montpellier and Smith failed to convert Lynagh's second try as Quins bowed out despite a 33-20 win.
Montpellier will face French opposition in the quarter-finals against either last year's runners-up La Rochelle or Bordeaux-Begles.
Fine margins cost Quins
Harlequins knew the task that faced them at Twickenham Stoop - win by more than 14 points or go out of Europe's premier club competition.
Supported by a buoyant crowd in the London sunshine, Quins crossed for the opening try in the first minute as Dombrandt broke through the Montpellier defence and fed Jones for a run-in.
The visitors hit back through Reilhac before Quins wrestled back momentum as Dombrandt powered over for their second try.
The pick of the tries was dotted down by Marchant as Danny Care kept the ball in play by flicking it behind his back to Smith, who set off on one of his trademark runs, evading blue shirts in his path before the centre finished off.
Tisseron pegged Quins back again but Lynagh crossed just before the break to help send the hosts in with an 11-point lead, just three shy of the required target.
The second half was less open as Montpellier dug in against the hosts' onslaught and the visitors cut the lead through a Handre Pollard penalty, but they could not prevent Lynagh's second try as he latched on to Smith's neat pass.
That score put the game in Quins' sights, but Smith uncharacteristically dragged his conversion wide of the posts to the amazement of the home fans who had already begun to cheer in expectation before realising their fly-half had missed.
Quins were worthy winners on the day as they played with real attacking intent, but the damage was done in the first half in France last weekend where they shipped 26 points without reply prior to the break.
Line-ups
Harlequins: Jones; Lynagh, Marchant, Esterhuizen, Murley; Smith, Care; Marler, Walker, Collier, Symons, Tizard, Hammond, Evans, Dombrandt (capt.)
Replacements: Gray, Kerrod, Louw, Jurevicius, Wallace, Gjaltema, Edwards, David
Montpellier: Tisseron; Ngandebe, Reilhac, Pollard, Lucas; Foursans, Eymeri; Nariashvili, Guirado, Thomas, Verhaeghe, Willemse, Ouedraogo, Camara, Becognee.
Replacements: Maurouard, Rodgers, Lamositele, Mercer, Doan, Doumayrou, Bouthier, Chalureau