A tight first half saw Oliver Gildart and John Bateman go over for the home side, with Benjamin Jullien and Ryan Atkins replying for Warrington.
Wigan's two-point half-time lead was wiped out when Ben Currie scored in his first game since September 2016 after recovering from a serious knee injury.
Two successive Stefan Ratchford penalty goals secured Wire a vital away win.
Wigan, who had captain Sean O'Loughlin celebrating his 400th appearance for the club, remain four points behind Super League's top four, while Warrington's victory keeps alive their slim hopes of a top-eight finish with one match to play until the Super 8s split.
They must rely on Huddersfield losing their next two games and then beat Widnes on 20 July to avoid the Qualifiers.
The hosts went ahead after 68 seconds when Thomas Leuluai's diagonal bobbling kick was picked up by Gildart to go over in the left-hand corner, but Warrington reacted well and Ratchford's short pass saw Jullien force his way through from close range.
Despite being outplayed in the first quarter, Wigan went back in front with O'Loughlin found Leuluai, who freed Bateman to run in to the right of the posts.
With half-time approaching, Declan Patton's kick to the left-hand corner was pushed down by Tom Lineham for Atkins to reduce Warrington's deficit to two points.
Wire, who lost to Wigan in last year's Grand Final, went ahead as Currie dived over from a kick through by Patton, who missed the conversion attempt to go with two earlier failed kicks from Ratchford.
But Ratchford was accurate with two successive penalty goals in the last 20 minutes as Warrington ended a five-game streak without a win against the Warriors.
Wigan Warriors coach Shaun Wane:
"It was a massive game, the 400th for Lockers (Sean O'Loughlin) and we had loads of reasons to win the game, but I didn't see the desperation.
"We owed him a victory and we didn't get it. That's why I feel bad and really angry. I'm really disappointed and they know that.
"One hundred per cent Warrington deserved to win. They had too much enthusiasm for us which is something you can't practice. They had better line speed and ran harder."
Warrington Wolves coach Tony Smith:
"Defensively I thought we were outstanding. Wigan are always going to ask questions of you, so to limit them to 10 points was very good.
"The first half try they scored was dubious or I don't know the rules, but I'm glad my boys were able to dig in for each other and come through."
On Ben Currie: "Aside from his try, I thought he was terrific. I thought he did everything that was asked of him and more. It showed what a class player he is, while ever there was a need for kick pressure, he was there. He didn't look as if he's been out all year, it's great to have him back."
Wigan: S Tomkins; Marshall, Gelling, Gildart, Burgess; Williams, Leuluai; Nuuausala, McIlorum, Sutton, Isa, Bateman, O'Loughlin.
Replacements: Clubb, Powell, Tautai, Wells.
Warrington: Ratchford; Hiku, Pomeroy, Atkins, Lineham; Patton, Gidley; Hill, Clark, Sims, Jullien, Hughes, Cooper.
Replacements: Currie, Savelio, Philbin, Smith.
Referee: James Child.
Warrington kept alive their hopes of a place in Super League's top eight with victory at rivals Wigan Warriors.