Trinity were left kicking themselves just before the hour mark as Liam Marshall scored a decisive - and his hat-trick - try after a tight opening 60 minutes.
The flying winger scored straight from a 20-metre restart as he strolled through the Wakefield line before racing clear for his third try of the afternoon.
The try proved contentious, however, as Marshall appeared to be off the centre mark when taking the tap.
Until that point it had been a tense and ferocious affair, with the game vitally important to both clubs but for very different reasons.
Wigan were battling to move into second while a win for Wakefield would have all but secured their Super League status for another season.
Trinity’s destiny is still in their own hands after Leeds Rhinos 36-10 triumph at London Broncos kept Danny Ward’s side in bottom spot with two games to play.
Ben Jones-Bishop brought the hosts to within two points of levelling matters when he pounced to ground Morgan Escare’s inventive kick just over 10 minutes from time.
But Wigan sealed their success just before the full-time hooter when Sam Powell dived over next to the posts.
Things were made more difficult for Wakefield when they lost two players to injury in the first half, forcing them to play the rest of the game with only 15 men.
Bill Tupou was withdrawn on 25 minutes after receiving some treatment and just seven minutes later his replacement, Chris Annakin, was stretched off with a potentially serious injury.
There was little in the way of clear-cut chances in the opening quarter with both sides guilty of unforced errors.
Wakefield defended well but were twice guilty of handing two tries to a clinical Warriors side.
After a scrappy opening 20 minutes Wigan pounced on a Trinity mistake to take the lead.
The ball was spilled on the right wing by the hosts and Liam Marshall picked up the loose ball and raced 80 metres for his 14th try of the season.
The Warriors soon grabbed their second after another error from the home side. Trinity had done well to repel a Wigan attack but lost the ball on the first tackle after the turnover.
Wigan wasted no time in punishing Wakefield as they worked the ball to George Williams who produced a superb cut-out ball for Marshall to burst over for his second.
Chris Chester’s side were back in it on the half hour when a loose ball was poked into the Wigan in-goal and James Batchelor beat Williams to the ball to plant down.
Hardaker, making his 250th career appearance, slotted a penalty to put Wigan six points ahead soon after but Wakefield were level going into the interval.
Kelepi Tanginoa, moved into centre in Tupou’s absence, and showed brilliant pace to break down the left-hand side and find Morgan Escare on his inside.
The French full-back gave it to Trinity captain Jacob Miller, who twisted out of the tackle and stretched out to plant down on the hooter.
The game remained tight and tense in the second half but it was the Warriors who eventually edged it with Marshall’s hat-trick score and Powell’s last-minute effort winning it for the visitors.
Wakefield Trinity: Escare, Jones-Bishop, Lyne, Tupou, Hampshire, Miller, Brough, England, Wood, Kopczak, Kirmond, Batchelor, Tanginoa. Subs: Randell, Annakin, Green, Tangata.
Wigan Warriors: Hardaker, Marshall, Sarginson, Gildart, Burgess, Williams, Leuluai, Clubb, Powell, Partington, Isa, Farrell, Smithies. Subs: Greenwood, Navarrete, Byrne, French.
Referee: Scott Mikalauskas.