Marcus Smith's last-gasp score capped a marvellous individual display and snatched the points from Wasps for 14-man Harlequins to boost their Premiership top-four hopes.
Quins led 24-22 at half-time but Mike Brown then saw red for a boot to the face of Wasps hooker Tommy Taylor.
Wasps looked like they would edge it, leading 46-41 with seconds to play.
But Smith sneaked down the short-side and then converted the extras coolly to deliver a precious win.
The victory could prove priceless for Quins, as it took full advantage of Northampton's defeat by Gloucester on Saturday to give them a nine-point buffer with the try-scoring bonus point.
Brown's sending off could yet have repercussions for him at the disciplinary panel, as he will likely be cited and face a hearing - and a ban could end his Quins career before his move to Newcastle this off-season.
In a game which went beyond two hours, and had almost everything you could envisage, two players - Smith and Dan Robson for Wasps - had their fingerprints all over the stellar moments.
Smith, who scored twice himself, showed creativity, sparkle and vision throughout.
His finest moments were a perfectly weighted kick into backfield space for Joe Marchant's score as well as perfect spiral passes for James Lang and Alex Dombrandt to cross.
Robson sniped and prompted for Wasps, who got a losing and try bonus point, and he did not deserve to finish on the losing side having created tries with his vision for Josh Bassett and Paolo Odogwu.
Harlequins: Brown; Green, Marchant, Northmore, Murley; Smith, Care; Marler, Baldwin, Louw, Symons, Lewies, Lawday, Kenningham, Dombrandt.
Replacements: Gray, Garcia Botta, Collier, Lamb, White, Landajo, Lang, Lasike.
Wasps: Robson; Umaga, Bassett, Fekitoa, Odogwu; Kibrige, Miller; West, Taylor, Brookes, Rowlands, Gaskell, Shields, Young, Willis.
Replacements: Oghre, McIntyre, Toomaga-Allen, Cardall, Morris, Porter, Atkinson, Le Bourgeois.