Bradford got off to a great start scoring two tries in the first 15 minutes from Lesley Vainikolo, but Paul Deacon missed both conversions.
Chad Randall pulled back six points with a try converted by former Bulls star Henry Paul, only for Shontayne Hape to restore the Bulls? eight-point lead four minutes later.
The game turned in five mad minutes around the half hour mark. Luke Dorn started it in the 27th minute with a long-range interception try, picking off a Deacon pass.
A beautiful piece of handling by Matt Gafa set up Lee Hopkins for another try three minutes later and the home fans could not believe their eyes when Randall burrowed over the line from acting half-back. Suddenly it was Harlequins who had the eight-point lead.
The second half started with Paul Sykes kicking the ball along the ground dead in goal to force a drop out by the Bulls. Tyrone Smith finished off the move by taking Rob Purdham's pass to crash over near the touch line. Although Paul missed the conversion the Quins led by 12.
But Bradford hit back quickly when Deacon took a short pass from Terry Newton on a last-tackle play and withstood a juddering hit from Danny Williams before stretching to touch down over the line.
A high tackle from Newton gave Paul the chance to kick another goal and it proved to be the difference as Brett Ferres scored a final try for the Bulls, following a kick from Stanley Gene.
There were still 25 minutes to play at this stage and Bradford launched numerous raids but the Harlequins line held firm for a famous victory.
Harlequins RL: Sykes, Stewart, Gafa, Smith, Bradley-Qalilawa, Paul, Dorn, Mills, Randall, Heckenberg, Hopkins, Noone, Purdham. Replacements: Budworth, Williams, Haumono, Tookey.
Bradford: St Hilaire, Vainikolo, Hape, B. Harris, Bai, I. Harris, Deacon, Vagana, Newton, Lynch, McKenna, Ferres, Langley. Replacements: Gene, Meyers, Withers, Henderson.
Harlequins RL: (22) 28. Tries: Randall 2, Dorn, Hopkins, Smith. Goals: Paul 4.
Bradford: (14) 26. Tries: Vainikolo, Bai, Hape, Deacon, Ferres. Goals: Deacon 3.
Referee: Ben Thaler (Wakefield)