Sam Powell darted over for a last-minute try to seal a tense victory which propels Wigan to second in the Super League table.
The Warriors were clinging onto an 18-16 lead - thanks to Liam Marshall's hat-trick - when Powell settled their nerves with seconds to go.
Hardaker's conversion, his fourth goal, was the last play of a scrappy match littered with errors.
But the manner of the victory did little to take away the delight for the travelling fans as they saw their side move two points clear into second, with their 10th win from their last 11 matches.
Wigan lost 30-20 at this venue earlier this season during a turbulent period which had Adrian Lam's side flirting with a relegation scrap.
They were in ninth position at the end of May, but they start September in second spot with just two matches left before the play-offs, at home to Catalans and Castleford on successive Fridays.
A second-placed finish would guarantee them a home match in the opening round of the play-offs, against the side finishing third; a victory would send them to St Helens to battle for a place in the Grand Final, while they would have the safety net of another match if they lost.
There were no surprises to the Warriors side, with Joe Burgess returning on the wing and Bevan French dropping to the bench.
Wakefield's side included on-loan Morgan Escare, who was allowed to face his parent club.
The Frenchman had a hand or foot in two of Wakefield's three tries and was one of the eye-catching players in a spirited Trinity side.
Liam Farrell crossed early but had a try ruled out for forward pass.
It was a spiky affair, with frequent interruptions, terrible handling and occasional moments of quality. Tony Clubb led the Warriors' defensive effort and played 35 minutes before being rested.
Ollie Partington also caught the eye, and motored through 53 minutes before being rested.
Marshall snapped the deadlock midway through the first-half, defusing a Trinity attack and racing 80m down field to score. Zak Hardaker converted.
Both sides coughed up an alarming amount of ball and from one Wakefield spill, the visitors powered ahead, a sweet George Williams pass helping Marshall arc over for his second. Hardaker missed the conversion but at 10-0, it was beginning to look comfortable for Lam's men.
Trinity, though, battled their way back as James Batchelor pounced to ground Jacob Miller's grubber-kick. Danny Brough tagged on the extras.
The game was held up for several minutes as Chris Annakin received treatment before he was stretchered off. They had earlier lost centre Bill Tupou, too.
Hardaker poked Wigan six points ahead with a penalty but on the stroke of half-time, Trinity drew level with a stylish effort when Kelepi Tanginoa combined with Escare, and Miller finished despite Hardaker's best efforts.
Joe Greenwood and French were brought on in the final 25 minutes in an attempt to give their attack more potency.
French slotted in at stand-off, with Williams replacing Sam Powell at hooker. They retook the lead with a wonderful solo try from Marshall to complete his hat-trick. Having defused a kick in the in-goal, he rushed to take a 20m tap and smartly used the referee's position in the defensive line to blaze into the clear. Hardaker's conversion opened up a six-point gap.
Clubb returned and was held up over the line and Marshall went close to grabbing his fourth try when he chased French's improved stabbed kick.
And those close scrapes appeared to come back to haunt them when Escare's measured, bobbling grubber allowed Ben Jones Bishop to cross in the corner. Brough missed the conversion - giving the visitors a two-point lead heading into the final 10 minutes.
And they controlled the final few minutes well to dominate and choke the hosts' of possession, before Powell's try secured the two points.
Wakefield: Escare; Jones-Bishop, Lyne, Tupou, Hampshire; Miller, Brough; England, Wood, Kopczak, Kirmond, Batchelor, Tanginoa. Subs: Randell, Annakin, Green, Tangata.
Wigan: Hardaker; Marshall, Sarginson, Gildart, Burgess; Williams, Leuluai; Clubb, Powell, Partington, Isa, Farrell, Smithies. Subs: Greenwood, Navarrete, Byrne, French.
Referee: Scott Mikalauskas
Star man: Liam Marshall