Mike Brown scored two tries, either side of Joe Gray's first-half effort, while Nick Evans kicked 16 points as Harlequins became the first team to win a European tie at Toulouse in almost three years.
Harlequins led 15-10 at half-time but were forced to survive a second-half onslaught as well as the loss of sin-binned captain Nick Easter for the final 10 minutes.
Despite that, Evans kicked two late penalties after Brown's second try to claim a famous win while Toulouse were left to rue 12 missed points from the boot of Luke McAlister.
Scrum-half Jean-Marc Doussain scored a try among his 15 points though that was not enough for Toulouse, who remain top of Pool Six, but now only a point ahead of Harlequins and four clear of Gloucester.
There were few signs of the drama to come when McAlister opened the scoring with a penalty inside three minutes after Harlequins were penalised at a scrum, following Doussain's break.
Evans cancelled out that lead almost immediately when Toulouse were penalised for picking up a player in the maul from the re-start.
Harlequins' problems in the scrum continued as a third engagement led to a second penalty, though they escaped further punishment when McAlister struck his kick against the post.
Despite a poor playing surface both teams showed intent amid a hectic start and Quins claimed the opening try in the 11th minute.
The English team stole possession in midfield before Brown won the foot-race to Evans' smart kick to the corner to touch down.
Evans missed the conversion but was faring better than opposite number McAlister, off-target twice in the space of four minutes - including another in front of the posts, as Toulouse missed the chance to cancel out the 8-3 deficit.
Harlequins then grabbed a second try on 24 minutes after Evans' lofted kick found space behind the Toulouse defence. The bounce was kind to Quins and a swift interchange of passes ended with hooker Gray diving over. Evans converted for a surprise 15-3 lead.
Timoc Matanavou looked lively for the hosts and fellow wing Vincent Clerc thought he had responded for Toulouse but the final pass from Yannick Jauzion was ruled forward.
The pressure eventually told when Jean Bouilhou broke through for Yoann Maestri to score neat the posts.
Doussain took over the kicking and his conversion cut Harlequins' lead to five points at half-time before two penalties early in the second half put the French team ahead.
Quins were forced to defend as Toulouse moved up the gears, Brown making a try-saving tackle on Clerc.
Bouilhou missed his first effort but made amends moments later to stretch the Toulouse lead to 19-15 on 61 minutes.
No sooner had the game re-started but Tom Williams stole possession from Clerc and the attack ended with Easter off-loading to Brown who scampered through for his second try.
Evans converted and added a penalty as the game swung back in Harlequins favour 25-19, until Easter was shown a yellow card for infringing at a ruck.
Doussain squeezed over in the corner as Toulouse looked to make the most against seven forwards, but the scrum-half missed the conversion and Evans hit back with a brace of penalties late on as Quins held out for a rousing win.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The entire All Blacks apparel line has been updated for 2013/14. Check out the New Zealand All Blacks polo.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Gilbert Blitz 8S rugby cleat is a great cleat at a great price of $69.99. Get a new pair of cleats today.
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
The All Blacks Performance t-shirt is black with hints of blue from the training jersey. Very Cool.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.