Wigan Warriors 6 Castleford Tigers 4
Oliver Gildart marked his 100th Wigan game with a scrappy, nervy victory at the DW Stadium.
Sam Powell scored the only try as Adrian Lam's side registered back-to-back wins to move up a spot to eighth - ahead of the visit of lowly London Broncos on Thursday.
The Warriors trailed 4-0 at half-time but they improved after the break.
And while this was certainly no classic - there was a post-Easter hangover feel to it - they at least addressed issues about their porous defence.
Powell and Thomas Leuluai were among the better performers for Lam's side, managing the game well against a Cas' side which chewed up metres, particularly during a first-half they dominated.
Sean O'Loughlin (injury) and Powell (suspension) returned as expected but there was no Dan Sarginson, allowing Chris Hankinson a start at right centre. Morgan Escare and young hooker Amir Bourouh dropped out.
Wigan headed into the game knowing a loss would see Castleford become the second team in eight days - as well as St Helens - to complete a league 'double' over them this year following the Tigers' 38-28 triumph earlier this month.
In that game, Lam's side raced into a 20-0 lead before letting it slip from their grasp - but by half-time it was clear they would need to take another route if they were to claim the two points.
There was a flat feeling to the occasion and the first-half's action hardly set pulses racing, with Castleford leading 4-0 - all their points from the boot of Peter Mata'utia.
The big positive for Wigan was the fact they'd had such little ball and still kept their opponents try-less.
Granite-shouldered Thomas Leuluai led their defensive charge but with the ball they struggled to punch their way out of their own half. In one of their rare ventures into Cas' territory, Zak Hardaker had a try ruled out by the video referee.
In wild conditions - the big-screen wasn't put up because of the wind - Mata'utia struck penalties in the 25th and 38th minutes to poke the visitors ahead.
And he went close to scoring the game's opening try early from the restart, only to be denied by a desperate effort from Powell.
Wigan dialed it up a notch, and when Tuoto Egodo - match-winner in their meeting earlier this month - spilled inside his own 40m it presented the opportunity for them to attack Cas' line.
And their defence eventually creaked as Powell crossed for a short-range try which Hardaker converted, putting them 6-4 ahead by the 55th minute.
The try seemed to fuel the Warriors' confidence but errors still littered their attack - Hankinson was guilty of one spill, though he redeemed himself with a try-saving tackle on Egodo.
Gildart denied James Clare as the game entered the final few minutes with the match on a knife-edge.
And just when it appeared Wigan were poised to inflict the killer blow, Williams spilled Joe Burgess' - perhaps unnecessary - reverse pass from a left-edge break.
At the other end, Burgess defused an attacking kick as they held on for a narrow, nervy but much-needed win.
Wigan: Hardaker; Marshall, Hankinson, Gildart, Burgess; Williams, Shorrocks; Flower, Leuluai, Bullock, Isa, Greenwood, Partington. Subs: O'Loughlin, Powell, Tautai, Smithies
Castleford: Mata'utia; Clare, Minikin, Egodo, Eden; Trueman, Ashton; Watts, McShane, Maher, Clarkson, McMeeken, Massey. Subs: Milner, Clark, Peachey, Smith.
Referee: Chris Kendall
Starman: Sam Powell