Brent Sherwin had a hand in four of Castleford's five tries
Castleford condemned Wigan to their third successive defeat and their worst start to a season in 24 years.
Thomas Leuluai put Wigan in front with a try on 25 minutes before two scores in two minutes from Joe Westerman and Brett Ferres put Cas 16-6 in front.
Wigan debutant Karl Pryce touched down after the break but Cas extended their lead courtesy of Ferres and Kirk Dixon.
Tries from Darrell Goulding, Joel Tomkins and Shaun Ainscough saw Wigan hit back before a Michael Shenton try.
Brian Noble's side were made to pay for missed conversion attempts, with Australians Amos Roberts and Mark Riddell landing just one kick between them from five attempts.
The result will heap further pressure on the beleaguered Noble, whose side were booed off at the JJB following the final whistle.
Without three first-choice backs, Wigan gave debuts to Pryce, his first rugby league appearance since joining from union side Gloucester, and 19-year-old Ainscough.
The match began ominously for the Cherry and Whites when Castleford had two tries disallowed within the first 10 minutes.
All of Cas' best moves were orchestrated by scrum-half Brent Sherwin, who had a hand in four out of their five tries.
Two Dixon penalties gave the visitors a 4-0 lead before a fine solo try from World Cup winner Leuluai saw Wigan take the lead for the first time on 25 minutes.
Sherwin's smart grubber was pounced upon by Westerman on 34 minutes before second-rower Ferres touched down two minutes later, with Dixon adding the extras for a 10-point cushion at the interval.
Although Pryce brought Wigan to within six points of Cas after the interval, Terry Matterson's side hit back with two tries in four minutes through Dixon and Ferres.
Centre Goulding touched down Wigan's third try on 57 minutes before two tries in three minutes from second-rower Joel Tomkins and a memorable Ainscough 50-yard try reduced the deficit to two points.
But Castleford clinched the victory when Shenton went over for Cas' final try deep into stoppage time.
Wigan coach Brian Noble: "The reality of this competition is that it's won in October and not February.
"We need some urgency in relation to getting a couple of points and getting our season under way. But I've no doubt we've got a team in there and when we get everybody on deck, we'll be fine.
"We got caught with some elementary things defensively, which cost us dearly in the end; some individual one-on-one opportunities defensively really burnt us, and we've got to improve in that department."
Castleford coach Terry Matterson: "It was important we got off the mark.
"We created two or three opportunities early on and were in a position to dominate - but when Wigan get on a roll with the crowd behind them, they are hard to stop.
"In the end we found a way to win. We would have lost a lot of these games last year. It's two points, and we're away."
Bookmark with:
What are these?