Wigan came back from the dead with two converted tries in the last four minutes to snatch victory in a breathtaking finish.
The Warriors were staring at certain defeat when Kevin Brown's 74th-minute drop goal put Huddersfield 19-8 ahead but they struck back with late tries from Andy Coley and George Carmont - and Pat Richards held his nerve to land the match-winning conversion.
Huddersfield's misery was compounded when prop Darrell Griffin was sent off after the final whistle for dissent.
The outcome was harsh on former Wigan half-backs Luke Robinson and Brown, who did not deserve to be on the losing side. Brown helped create the game's first try for his half-back partner and scored his team's other.
Huddersfield were also indebted to teenager Leroy Cudjoe, who kicked five goals from as many attempts on his full debut and slotted in effortlessly at full-back in place of rib-injury victim Chris Thorman.
The game began as a stop-start affair with referee Phil Bentham awarding 10 penalties in the first 17 minutes, seven of them to the visitors, but eventually settled down into a war of attrition.
Wigan went in front with a goal from Richards, equalised by Cudjoe, and, although the visitors dominated the opening quarter, they could not break down a determined Huddersfield defence in which threequarters Shane Elford and Paul Whatuira were particularly outstanding.
The hard work paid off on 24 minutes when Brown slipped through the slightest of gaps in the Warriors defence and Robinson was on hand to take his pass and bounce off a couple of defenders to touch down for his sixth try of the season, despite a hint of a knock-on.
Cudjoe's conversion made it 8-2 but it was Wigan's turn to draw level five minutes later when the returning Mark Calderwood palmed back Trent Barrett's high kick to the corner into the grateful arms of centre Darrell Goulding.
Richards, who was switched to from wing to full-back in the absence of the suspended Richard Mathers, added the touchline conversion and Wigan missed a chance to go in front when left winger Liam Colbon was first to Barrett's high kick but knocked on with the line at his mercy.
Huddersfield regained the lead three minutes into the second half when a break from Ryan Hudson pulled the Wigan defence out of position and, from the play-the-ball, Brown jinked his way over for a try.
Cudjoe added the conversion and extended his side's lead to 18-8 with two further penalties as Wigan began to lose their discipline but he was denied a spectacular try when Calderwood got back to pull off a tremendous last-ditch tackle.
When Wigan rallied, Huddersfield needed a last-gasp tackle from Eorl Crabtree to bring down winger Colbon in full flight and Brown looked to have clinched victory with a drop goal seven minutes from the end.
But skipper Sean O'Loughlin burst through the Giants defence to send prop Coley over to give his side a glimmer of hope and Huddersfield had barely recovered from that shock when Carmont powered his way over wide out.
Richards maintained his composure with the difficult conversion to break Huddersfield's hearts and clinch a dramatic victory.