Wigan looked the better team for periods, and Leeds matched them in other areas for 80 minutes, though it was the hosts who kept ahead of the scoreboard for the majority of the game.
The Warriors led 24-18 with three minutes remaining before Rob Burrow crossed for the visitors, bringing his side level with enough time to snatch the win.
Leeds then broke deep in their own half and seemed to be on their way to victory, but in the lead up to the break the referee spotted Paul Aiton taking out a potential tackler and awarded Wigan the penalty. With 15 seconds remaining Matty Smith stepped up and slotted the kick that gave his side a dramatic win.
It was a game in which the two sides exchanged tries, penalties, knock-ons and scrums, with neither side able to take a substantial lead at any point.
The two sides initially struggled to fall into the rhythm of the game, and it was still the case when Paul Aiton spotted the Wigan defence not setting quickly enough on their own line to dart over for the opening try.
Wigan then started to take control as an overlap led to Dan Sarginson running down the left hand touchline before kicking ahead where Liam Farrell got ahead of the Leeds defence to claim his side’s first try of the game.
Wigan took the lead for the first time shortly after when Michael McIlorum delayed his pass to Sean O’Loughlin perfectly as he crossed over close to the posts. With both kickers on song, the score was 12-6 to Wigan.
The two sides exchanged further tries, as Brad Singleton drew his side level before Matty Bowen rose above Danny McGuire to claim a catch and reinstate his side’s lead, which they took into the break.
Wigan looked to be pulling away when Matty Smith put a deft kick through which gave Josh Charnley his first try of the night, but as was the case all night Leeds hit back, with Kevin Sinfield stepping across the Wigan defence before his kick was met by Ash Handley to make it 24-18.
It looked like the game would remain that way before Rob Burrow danced through the defence from close quarters to draw his side level.
Leeds then looked like they would take it when they broke up the field, but the referee spotted Paul Aiton taking out a defender and awarded a penalty to Wigan. Matty Smith stepped up and slotted the kick with 15 seconds remaining.