James Lang missed a last-minute long-range penalty as Harlequins failed to reach the Premiership play-offs after they fell to defeat at Wasps.
Josh Bassett's effort and Joe Simpson's double put Wasps 24-8 ahead with 25 minutes left but Danny Care's close-range try sparked a Quins revival.
After Lang and Lima Sopoaga traded penalties, Elia Elia's converted score put the visitors two points behind.
Lang then saw his kick drop just under the bar to consign Quins to defeat.
The south London side had appeared to be on course for their first top-four finish since 2014 in the spring, but six defeats in their final seven games meant Paul Gustard's side finished fifth - behind Northampton Saints on games won.
Quins were twice ahead in the first half, first through Marcus Smith's early penalty and then after Joe Marchant powered over in reply to Bassett's score, before Wasps took control.
Simpson crossed twice in the space of five second-half minutes, first with a pick and go from the breakdown and then being fed by Elliot Daly after a flowing move, to mark his final appearance following over a decade with the club.
Saints' defeat at table-topping Exeter, coupled with Elia's score five minutes from time, gave Quins hope that they could snatch the final play-off place but replacement fly-half Lang agonisingly missed with his late attempt from one yard inside his own half.
Wasps had started the day with faint hopes of securing the final European Champions Cup qualification spot but wins for Bath and Sale Sharks left them eighth in the table.
Wasps director of rugby Dai Jones told BBC Coventry & Warwickshire:
"It was important that we got the result to say thank you to the supporters and send the players that are leaving on their way.
"Unfortunately it wasn't enough to get into Europe, which is obviously disappointing. But it is not about today for that - it is 10 months of hard graft to earn the right to be there.
"We have earned the right to be there over the last three or four seasons but haven't earned it this year. There are always five quality teams who miss out.
"We have got to lick our wounds, take our medicine and come back a lot stronger next season."
Harlequins head of rugby Paul Gustard told BBC Radio 5 Live:
"I'm disappointed. Over the course of the game it ebbed and flowed.
"We know we had an opportunity and we have fallen short, which is hard to take.
"I think we have only got seven points from our last six games and we still finished fifth. It is bananas really but it shows you the competitive nature of the league.
"We are one win short of finishing in the top four and this is a team which almost got relegated last season.
"There is loads for us to work on, but I want to be a top-four team so I will look at things holistically and make sure we are a better team next year."
Wasps: Le Roux; Watson, Daly, Lovobalavu, Bassett; Sopoaga, Simpson; McIntyre, Cruse, Brookes, Launchbury (capt), Gaskell, Shields, Carr, Hughes.
Replacements: Taylor, Zhvania, Cooper-Woolley, Rowlands, Johnson, Hampson, Miller, de Jongh.
Harlequins: Brown; Chisholm, Marchant, Tapuai, Ibitoye; Smith, Care; Marler, Buchanan, Sinckler, Symons, Horwill (co-capt), Kunatani, Robshaw (co-capt), Clifford.
Replacements: Elia, Boyce, Collier, Merrick, Dombrandt, Hidalgo-Clyne, Lang, Alofa.