Wigan were left to count the cost of indiscipline as two late Brett Hodgson penalties snatched Super League top spot for Warrington at the DW Stadium.
Tries from Gareth Hock, Michael McIlorum and Pat Richards had given the home side the edge in a ferocious battle of third against second.
But Epalahame Lauaki twice infringed, allowing Hodgson to turn it round.
Wire's tries came from Ryan Atkins, Joel Monaghan and Lee Briers as they took over on top from Huddersfield.
Friday's contest came almost exactly a year to the day since Warrington ran out comfortable 24-6 winners on their last visit to the DW - and this proved to be their third straight win on Wigan soil.
The two sides were strongly tipped to meet again in last season's Grand Final, only to both be stunned in the semis, Warrington by Leeds and Wigan twice by St Helens.
But, on the same weekend when Saints and Leeds meet for the first time since Old Trafford, they will struggle to match this one for excitement and drama.
Lauaki's two late challenges, which both went 'on report', provided the main sour notes of a stunning contest. But this season's biggest game to date was otherwise a classic which could have gone either way.
With only a Richards penalty to emphasise Wigan's early dominance, Warrington then went up the other end to score in their first real attack.
The prolific Atkins went over in the left corner, Hodgson, back after missing two games with a back injury. adding a touchline conversion for a 6-2 lead.
But Hock then forced his way over for his third try in as many games, Wigan getting their noses back in front when Richards added the extras.
Michael McIlorum then became the second Wigan forward on the scoresheet when he cashed in on an advantage played by referee Richard Silverwood to steal his way over.
With Richards, already carrying a dead leg, having just come off the worse in a coliision with Sam Tomkins, it was left to Josh Charnley to stand in as kicker.
But he passed up the opportunity for an eight-point lead by slicing it wide. And, by half-time, Warrington were level again.
First, Richards' slip on the wet surface allowed winger Monaghan in at the right corner. And, although Hodgson missed from the touchline, he got another opportunity right on the half-time hooter when Jeff Lima transgressed at the play-the-ball 40 yards out - and this one sailed through the posts to tie it up again at 12-12.
Two minutes into the second half, Richards made light of his injury to go over in the left corner after Sam Tomkins appeared to have made a mess of his own stunning break up field.
An, although Charnley missed the touchline kick, a penalty in front of the posts six minutes later put Wigan six points in front again.
That lead lasted just two minutes before Briers read a Thomas Leuluai pass to unleash one of his trademark interception tries, Hodgson tieing it up again at 18-18.
A second Charnley penalty on 55 minutes then edged the home side back in front and the clearly far from fully fit Richards had a try disallowed for putting a foot in touch as Wigan began to look the more likely winners.
But, as the tension mounted, tempers became frayed and Wigan prop Lauaki charged in leading with his elbow to concede a 67th-minute penalty. And, when the winter signing from Hull infringed again, to conceded another penalty, Hodgson kept his cool to win it.
Richards' try and two goals took him past 2,000 points for the club. But Hodgson had the final say on only his third appearance of the season, kicking five of his six goal attempts, while Charnley's two missed kicks proved costly.
VIEW FROM THE DRESSING ROOM
Wigan coach Shaun Wane:
"Epalahame Lauaki is absolutely devastated. He thinks he's lost us the game. I rate him and he's been great for me this year. He was great again tonight but he needs to be smarter. He let himself down by not concentrating on his tackle technique."
"It was probably good to watch but it was disappointing from my point of view. If we had showed some composure in the last 20 minutes we would have won.
"We need to be better. I've said that a few times this year. We've a lot to work on."
Warrington coach Tony Smith:
"We're doing it the hard way. It was fantastic to watch I'm sure, but it's frustrating for players and coaches.
"There was a bit of anxiety among the players. They are trying hard and they were gutsy and determined.
"Sometimes it goes your way and sometimes it doesn't. There is not much between the top teams. It's fine-line stuff, it could easily have gone Wigan's way tonight."
FRIDAY NIGHT'S LINE-UPS
Wigan: S Tomkins; Charnley, Goulding, Carmont, Richards; Finch, Leuluai; Prescott, McIlorum, Lauaki, Hansen, Hock, O'Loughlin.
Replacements: Lima, Farrell, Tuson, Flower.
Warrington: Hodgson; Riley, Bridge, Atkins, J Monaghan; Briers, Myler; Morley, M Monaghan, Cooper, Waterhouse, Westwood, Grix.
Replacements: Wood, Blythe, Hill, Dwyer.
Referee: Richard Silverwood (Dewsbury).