Oliver Partington scored his first try for Wigan to help them to a 23-14 win over Leeds in a tense Super League clash at Headingley.
Leeds twice held the lead before Partington came up with the all-important score on the hour and Wigan produced some superb defence to keep their lead intact in a tense final quarter, completing the double over the Rhinos.
Wigan's final margin of victory was inflated by a freak try in the final seconds from prop Tony Clubb, who picked up a loose ball as Leeds chased victory on the hooter and had enough space and pace to reach the corner.
The win enabled the reigning champions to finish a difficult week on a high after they were rocked by another off-field misdemeanour which cost forward Taulima Tautai his place in the team as he awaits the result of an internal inquiry into his drink-driving conviction.
Leeds, buoyed by back-to-back wins for the first time this year, ought to have made more of an early long-range break from scrum-half Richie Myler while his opposite number Thomas Leuluai had a try disallowed for obstruction.
Stand-off Liam Sutcliffe gave the home side the lead with a 17th-minute penalty but it lasted only four minutes as Wigan's England centre Oliver Gildart handed off Harry Newman to go in for the first try of the match.
Chris Hankinson, handed the goalkicking duties in the absence of former Leeds full-back Zak Hardaker, landed the touchline conversion and also added two penalties to extend his side's lead to 10-2 as the Warriors punished the Rhinos' indiscipline.
Leeds pulled a try back six minutes before half-time when hooker Brad Dwyer, their best player, got substitute prop Adam Cuthbertson charging over from 10 metres out.
Sutcliffe added the conversion but Wigan hooker Sam Powell, whose late drop goal earned his side victory in their last match at Hull KR, put over another one-pointer on the stroke of half-time to make it 11-8.
The Rhinos looked certain to retake the lead seven minutes into the second half when Cuthbertson took an offload from Ash Handley to charge towards the line, only to be brought down in Dan Sarginson's last-ditch tackle.
The home side suffered a blow when Sutcliffe was forced off for a concussion assessment but they quickly shrugged it off and went in front on 51 minutes when Dwyer got loose forward Trent Merrin crashing over for their second try.
This time Tui Lolohea kicked the conversion to make it 14-11 but the lead changed hands for a third time when Wigan earned a goal-line drop-out and Farrell switched the direction of play to get substitute Partington in for their second try.
The score came against the run of play and Wigan were forced into some desperate defence to keep their lead intact.
Prop Ava Seumanufagai got over the line only to be held up and Merrin lost his grip on the ball as he forced his way over and Leeds were chasing the game when Clubb struck with the game's final try.