Two tries from young full-back Lee Smith had given the Rhinos a 22-18 lead going into the dying stages, only for Hansen to barge his way through four Leeds players for a sensational score that allowed man of the match Danny Orr to convert and win the game.
The Warriors, missing nine first-teamers, had been running on empty for the vast majority of the second half but pulled something out of the bag when it mattered and inflicted a third successive defeat on Tony Smith?s men.
Wigan had held a slender half-time advantage thanks largely to superb link-up play from their half-backs Orr and Dennis Moran, but they were hanging on in the second period in the face of a battering from the Rhinos, who looked as though they were going to take the spoils until Hansen?s late show.
Orr and Moran have been largely responsible for Wigan?s resurgence in the last month, and they combined beautifully to set their side up for the two points they desperately need to keep them in the play-off picture.
For Leeds, Chev Walker and Andrew Dunemann crossed the whitewash, but they were struggling to find their usual fast and fluent style for long spells.
Wigan had welcomed back winger Brian Carney and prop Jerome Guisset, although fellow prop Jerry Seuseu this week became the eighth Wigan player to be ruled out for the rest of the season through injury.
Leeds had been forced to throw in youngster Smith at full-back after Richard Mathers went down with gastric flu just hours before kick-off, while Keith Senior and Chris McKenna were also missing from duty through injury.
Both teams had gone into the game with something to prove ? the Rhinos looking to bounce back after last weekend?s disappointing Powergen Challenge Cup final defeat to Hull, and the Warriors seeking to avenge the 70-0 humiliation they suffered at Headingley a couple of months ago.
The opening stages were not for the faint-hearted, one big shoulder-charge by Guisset on Ryan Bailey drawing winces from the stands.
Bailey came back with two retaliatory big hits of his own ? however, both were above the shoulder and, unfortunately for Brian Carney, both connected with Wigan?s Irish winger instead of their French prop.
The Warriors opened the scoring after 15 minutes, and it was a beautifully worked effort involving Wigan?s three in-form men of the moment.
Hooker Terry Newton produced a fabulous slipped-ball out of a two-man tackle to Orr, and when he approached Smith he kicked ahead for Moran to touch down by the posts.
The Rhinos? response was swift, however, and it came courtesy of one of the tries of the season from their stand-in number one.
Fielding a deep kick from Orr, Smith stepped his way through the initial line of defence, before staggering through a half-tackle from Brett Dallas and then regaining his momentum to outpace the chasing cover and take Martin Aspinwall over the line with him.
Kevin Sinfield?s missed conversion meant Wigan retained a narrow two-point lead, and they extended that halfway through the first half when Orr took the ball from Moran at a scrum and darted through the line to score under the posts. Danny Tickle?s second goal opened up a 12-4 lead.
The Rhinos hit back, though, with two tries in three minutes around the half-hour mark through Walker and Dunemann, both converted by Sinfield, to take the lead for the first time at 16-12.
Walker showed a fine turn of pace to register his four-pointer, while Dunemann?s score owed much to the excellent lead-up play of Rob Burrow and a superb final short ball from Sinfield.
Moran ensured Wigan held the lead at the break, however, by dummying his way through just before the hooter to leave Tickle with an easy conversion.
The Rhinos came out fired up for the second half, and only spirited defence from Wigan kept the Yorkshiremen out.
Wigan were making less and less ground from their sets of six and more and more of the game was being played out in Wigan territory.
Twice it seemed certain Leeds would score from repeat sets only for desperate home tackling to hold them at bay.
However Leeds did eventually hit the front on the hour-mark when Walker intercepted and fed McGuire.
Wigan did well to get back and stop the speedy half-back, only for Smith to grab his second try of the night on the next tackle through some very tired defence.
That looked to be the winner ? until Hansen popped up in the dying moments.
Wigan: Dallas, Carney, Brown, Vaealiki, Aspinwall, Orr, Moran, Hargreaves, Newton, Guisset, Wild, Tomkins, Tickle. Replacements: Sculthorpe, Hansen, Allen, Beswick.
Leeds: Smith, Calderwood, Walker, Ellis, Bai, Sinfield, Burrow, Bailey, Diskin, Ward, Lauitiiti, Jones-Buchanan, Dunemann. Replacements: McGuire, Poching, Scruton, McDermott.
Wigan: (18) 24. Tries: Moran 2, Orr, Hansen. Goals: Tickle 3, Orr.
Leeds: (16) 22. Tries: Smith 2, Walker, Dunemann. Goals: Sinfield 3.
Referee: R Lawton (Barnsley) Att: 14,158
- - - - -
Thanks to www.superleague.co.uk for this news.Like