Gloucester secured a consolation victory in the final Pool Six match in the Heineken Cup, but Toulouse still topped the group despite their defeat.
The Cherry and Whites had no chance of qualification but rallied from 17-14 down at half-time at Kingsholm.
Jonny May scored twice and Freddie Burns kicked 14 points in a fine win.
Harlequins were second in Pool 6 but must wait for the weekend's other games before discovering if they will qualify as one of two best second-placed teams.
Four-time winners Toulouse ensured a place in the last eight for the 13th time since the tournament began in 1995, but their weaknesses were exposed by a Gloucester renaissance full of adventure and creativity.
The home side seized the early advantage as Timoci Matanavou's clearance from behind his own line went straight to May, who touched down.
Matanavou then showed his searing pace in attack, setting up Thierry Dusautoir, who galloped 45 metres unopposed to the line.
Matanavou finished off a crisp passing move to cross for a second try, also converted, but 12 minutes before the break Gloucester began their resurgence.
An impressive burst from Charlie Sharples took him into the Toulouse 22, flanker Alasdair Strokosch kept the move alive and a delicate pass from Burns was collected by Qera to touch down.
Gloucester began the second period in similar fashion and unlocked the French defence again when a well-placed Mike Tindall kick was gathered by May and Sharples completed the try.
Burns maintained his 100% conversion success rate, although only after referee George Clancy consulted the television match official when neither assistant referee raised his flag, and replays showed the kick had crept over the bar after striking a post.
The visitors produced another score when a midfield break from Lionel Beauxis freed Matanavou to record his second try but another Burns penalty and May's second try ensured Gloucester of a bonus point to complete their campaign.
Gloucester coach Bryan Redpath:
"It was a great performance.
"We knew they had picked a big, physical side and we showed them a lot of respect. I thought numbers one to 23 - our substitutes that came on made a big difference as well - were great.
"I am delighted for the boys because we finished off the Heineken Cup in style."
Gloucester: May, Sharples, Tindall, Fuimaono-Sapolu, Simpson-Daniel, Burns, R. Lawson, Wood, S. Lawson, Harden, Hamilton, Brown, Strokosch, Qera, Narraway.
Replacements: Mills for Tindall (65), Lewis for R. Lawson (74), Murphy for Wood (71), Dawidiuk for S. Lawson (56), Knight for Harden (63), James for Brown (71), Cox for Qera (70). Not Used: Trinder. Sin Bin: Wood (1).
Toulouse: Poitrenaud, Matanavou, Fritz, Jauzion, Medard, Beauxis, Burgess, Steenkamp, Servat, Johnston, Maestri, Albacete, Nyanga, Dusautoir, Picamoles.
Replacements: Donguy for Poitrenaud (71), Doussain for Burgess (63), Human for Steenkamp (49), Poux for Johnston (55), Lamboley for Maestri (49), Bouilhou for Nyanga (60). Not Used: Tolofua, Sowerby.
Referee: George Clancy (RU).