Wasps (13) 21
Tries: Haughton, Lemi Con: Walder Pens: Walder 3
Toulouse (7) 16
Try: Jauzion Con: Skrela Pens: Skrela 3
Lemi's last-minute score means Toulouse must travel to Biarritz in the last eight
David Lemi's last-minute try denied Toulouse a home Heineken Cup quarter-final as Wasps prevailed at Adams Park.
Yannick Jauzion scored an early try but Wasps led 13-7 at half-time thanks to a Richard Haughton try and two penalties and a conversion from Dave Walder.
The visitors had Florian Fritz sent off for a spear tackle on Tom Varndell and Walder extended Wasps' lead to 16-7.
Three David Skrela penalties levelled it but Lemi's late try means Toulouse now have to travel to face Biarritz.
Had the group winners held on for the draw, they would have been rewarded with a home clash against Pool Three winners Toulon.
Having failed to go through as one of the two best runners-up, Wasps will resume their European campaign with an Amlin Challenge Cup quarter-final away to Premiership rivals Harlequins, with the winners to face either Brive or Munster.
A Wasps victory had looked highly unlikely in the opening exchanges - Toulouse ominously turning over a scrum and winning a penalty from the resulting phase only for Skrela to screw his kick wide.
The reigning champions were also pinging the ball about with considerable panache early on, with teenager Jean-Marc Doussain, a fly-half operating at scrum-half, impressing with some glorious sweeping passes.
Wasps' scramble defence, however, was holding firm - Mark van Gisbergen halting a rampaging Census Johnston after the Samoan prop had broken the line down the middle.
In the 11th minute, though, Wasps' Kiwi full-back was found wanting as the French side broke the deadlock.
Clement Poitrenaud gathered a clearance unchallenged and his quick offload set Maxime Medard off on a run to the corner. Centre Jauzion collected a switch-pass on the outside, brushed aside a meek Van Gisbergen tackle and ran over all too easily.
Skrela added the extras and, moments later, outside centre Fritz belted a long-distance penalty wide.
Despite their territorial dominance, Toulouse had failed to pull clear, and the Londoners got off the mark in the 27th minute when Walder fired over a penalty after a ruck infringement.
It got better for Wasps, when, with eight minutes of the half remaining, number eight Louis Picamoles was sin-binned after tempers had flared on the touchline.
The home side made their man advantage tell immediately as Joe Simpson's inside pass on the 22 allowed replacement Haughton, on for Van Gisbergen, to scamper over before Walder converted.
In the 38th minute, a high tackle on Simpson yielded another kick at goal and Walder was again successful off the tee.
It was a fruitful period for Wasps but they could have made Toulouse pay more dearly for their indiscipline when try-scorer Haughton wove his way through the first defensive line before being caught by Vincent Clerc just before he got his pass away with the support arriving in numbers.
As it was, their advantage was just six points at the interval.
After the restart, Haughton continued to prove a handful - launching a superb counter-attack that eventually resulted in Varndell collecting a perfectly-judged Walder cross-kick.
Varndell ran into trouble but was needlessly spear-tackled by Fritz, who justifiably saw red for his over-zealousness. Fritz's departure was even less dignified than his foul - an inflammatory gesture with his finger aimed towards the home fans.
Walder added three points from the penalty, but that was negated when number eight Andy Powell was isolated just inside his 22 and Skrela knocked over the resulting penalty.
The error count began to rise for Wasps - an ill-judged Haughton kick-and-run and a clumsy knock-on by Dominic Waldouck symptomatic of their diminishing concentration.
More Wasps ill-discipline allowed Toulouse to level when Serge Betsen saw yellow for diving off his feet at a ruck before Skrela's kick came off the left-hand upright to make it 16-16.
Prompted by scrum-half Nicolas Vergallo - who had replaced 19-year-old Doussain after his bright start had turned sour with some poor handling and dubious decision-making - Toulouse continued to work through the phases. But even without Betsen, the Wasps pack - inspired by veteran Simon Shaw throughout - were not about to roll over.
A Skrela drop-goal attempt sailed narrowly wide before Betsen returned to the action to restore the Premiership side's numerical advantage.
And Wasps ended on the front foot, Simpson scuffing a grubber kick as he was tackled on the left only for Lemi to get his foot on the loose ball and beat Vergallo in a 10m sprint to get the touch in the corner for the decisive try.
Wasps director of rugby Tony Hanks:
"There are mixed emotions in the changing room. The guys can look at themselves in the mirror and be very proud of their performance.
"Everyone was really hurting this week. The first couple of days were horrible but we fronted up well.
"But there will be plenty of times in the next few months, especially when we are watching the Heineken Cup quarter-finals, when we will think about what could have been.
"But we have to move on. We are in the Amlin Challenge Cup and we play our local rivals."
Wasps: Van Gisbergen, Varndell, Jacobs, Waldouck, Lemi, Walder, Simpson, Payne, Lindsay, Taulafo, Shaw, Birkett, Worsley, Betsen Tchoua, Powell.
Replacements: Haughton for van Gisbergen (23), Beech for Payne (77), Ward for Lindsay (70), Broster for Taulafo (70). Not Used: Veale, Cannon, Berry, Flutey.
Sin Bin: Betsen (63).
Toulouse: Poitrenaud, Clerc, Fritz, Jauzion, Medard, Skrela, Doussain, Human, Servat, Johnston, Maestri, Albacete, Nyanga, Dustautoir, Picamoles.
Replacements: Michalak for Doussain (55), Poux for Human (50), Montes for Johnston (74), Lamboley for Maestri (69), Heymans for Nyanga (50), Sowerby for Picamoles (50).
Not Used: Lacombe, Vergallo.
Sin Bin: Picamoles (32). Sent Off: Fritz (47).
Referee: A Roland (IRFU)