Wakefield hit a purple patch in the last quarter of a dramatic match to recover a 14-point deficit and clinch a fourth successive win.
Harlequins looked to have completed a Super League double at a sun-kissed Belle Vue after running in four tries in an 11-minute spell to establish a 20-6 half-time lead.
But the Wildcats, who were still without nine senior players, scored three tries in 13 minutes, including one from former London Broncos centre Tony Martin, to snatch the points.
The home side were once more indebted to skilful half-backs Danny Brough and Jamie Rooney, who scored two of their four tries, including the first after only eight minutes.
A 40-20 kick from Brough set up the position for his partner to cross after taking a return pass from centre Ryan Atkins.
Brough added the conversion to give his side a deserved 6-0 lead but the game was transformed as Harlequins turned on the style to cut the Wildcats defence to ribbons.
Former Castleford and Wigan scrum-half Danny Orr took Chad Randall's pass to slice through for an equalising try and the visitors hit the lead on 15 minutes when stand-off Scott Hill marked his return from injury with a pinpoint pass to get centre Matt Gafa over for his 10th try of the season.
The touchdowns injected even more confidence into the Londoners' ranks and their next scores provided two candidates for try of the season.
An offload from prop Karl Temata freed Orr and he sent second rower Michael Worrincy away for a 60-metre score and there was more breathtaking brilliance four minutes later when loose forward Rob Purdham came up with a break and Randall, Orr and Gafa combined to get winger Rikki Sheriffe over.
Purdham kicked his second conversion to make it 20-6 and Harlequins would have been out of sight by half-time had referee Steve Ganson not disallowed further tries by Worrincy and Joe Mbu.
Sheriffe went close early in the second half following a half-back from Purdham but the visitors suffered a blow on 46 minutes when Hill had to go off after catching a stray boot in the face.
Wakefield, who brought on former Castleford and Widnes winger Damien Blanch for his debut, ought to have made more of a clean break from Atkins and Martin had a try disallowed for a knock-on in the build-up.
The home side began the fightback on the hour when Rooney touched down a deft kick from Brough, who added his second conversion to cut the deficit to eight points.
Atkins then had a try disallowed for a forward pass but Wakefield halved the gap on 66 minutes when Brough re-gathered his own kick and Rooney's long ball enabled Martin to cross unopposed for his side's third try.
Brough missed his first kick of the match but he was back on target shortly afterwards when hooker Sam Obst jinked his way over for a fourth try from close range to edge the Wildcats back in front and gave them some breathing space with a late penalty.
In an exciting finish, Wakefield needed a flying tackle by Leo-Latu to deny Harlequins winger Tony Clubb what would have been a match-winning try.