Tansey (centre) provided the knock-out blow to Bradford
Bradford: (26) 38
Tries: Platt (2), Vainikolo, Henderson, B Harris, Lynch
Goals: Deacon (7)
Leeds: (18) 42
Leeds snatched a last-gasp win over Bradford in controversial circumstances to return to the top of Super League.
Tries: Jones-Buchanan, Webb (3), Senior, Burrow, Tansey
Goals: Sinfield (7)
Bradford led 38-36 with a minute to go when referee Steve Ganson penalised Matt Cook for offside when the ball had come off a Leeds player's boot.
Kevin Sinfield's kick at goal hit the bar and Jordan Tansey was quickest to react, claiming the winning try to the anger of the Bulls players and fans.
The end overshadowed a great game, with 13 tries and a Brent Webb hat-trick.
The Leeds-Bradford derby matches have produced many classics over the years, but there can never have been a more dramatic end to an encounter between the rivals.
Michael Platt was first on the scoreboard for Bradford before Jamie Jones-Buchanan scored for Leeds, touching down after a sensational reverse pass off his bootlaces from Scott McDonald.
Leeds then went ahead when Danny McGuire literally skipped out of a challenge and off-loaded to Webb, who sprinted 40 yards to touch down.
McGuire then came within inches of scoring himself but Lesley Vainikolo's perfectly timed tackle put him in touch.
Bradford regained the initiative in a game being played at a breathless pace as the Rhinos dropped their guard for a second.
Several players turned their back on the ball as Iestyn Harris was tackled, thinking the tackle ahd been completed, but he offloaded to Terry Newton, whose pass found Platt to score his second try.
Then Vainikolo, who looks poised to leave Bradford soon, showed what they will be missing when James Evans' one-handed pass put him over in the corner.
With time running out in a frantic first half, Keith Senior ran through Evans to pull one back for Leeds only for Bradford's Ian Henderson to dispossess Jamie Thackray in the tackle and dive over to score.
Sinfield kicked seven goals in the Rhinos' win
Webb claimed the first try of the second half, shortly before earning himself a spell in the sin-bin for persistent backchat to referee Ganson.
The teams then continued to trade tries - Ben Harris and Andy Lynch for Bradford scoring either side of Rob Burrow's scamper over the line for Leeds.
Webb then completed his hat-trick with a disputed touchdown after a possible knock-on by Gareth Ellis to set up a grand final.
Bradford had potential tries - by Platt and Vainikolo - ruled out for infringements by the video referee as the tension grew.
Leeds ended the game on the front foot, but despite all their efforts, it looked like the Bulls had done enough to hold on.
But there was one more twist in the tail of the Millennium Magic weekend, and when Tansey touched down - as the final hooter sounded - and Sinfield converted, there was no time for Bradford to reply.
The Bulls players complained that Tansey had been in front of the kicker - and therefore offside - but the try stood.
Bradford: Platt, McAvoy, B. Harris, Evans, Vainikolo, I. Harris, Deacon, Vagana, Newton, Lynch, Cook, Solomona, Langley.
Replacements: Halley, Henderson, Kopczak, Burgess.
Leeds: Webb, Donald, Toopi, Senior, Smith, McGuire, Burrow, Thackray, Kirke, Leuluai, Jones-Buchanan, Ellis, Sinfield.
Replacements: Hall, Lauitiiti, Ablett, Tansey.