Prop Tony Clubb charged over for a surreal try to add the crowning glory to a gutsy win at Headingley.
Wigan were defending a slender 17-14 lead in a nervous finish when Clubb collected the ball, and rolled back the years to his centre days with a touchdown which proved a belated birthday gift - he was 32 yesterday.
Emergency goal-kicker Chris Hankinson added the extras to make it a perfect five goals to help propel Wigan to within touching distance of the top-five.
The Warriors were the smarter and tidier of two desperate sides, their error-count was low and they were industrious, even if their attack close to the line again lacked a cutting edge.
Still, many would have taken successive wins at Hull KR and Leeds in a week - no matter how they were scraped and scrapped for - and this moves Wigan to within just two points off a play-offs position.
In a spirited performance, fringe players Morgan Smithies, Oli Partington and Hankinson bolstered their burgeoning credentials.
Injuries to Zak Hardaker and Ben Flower forced Lam into making changes, with Dan Sarginson switching to full-back and Romain Navarrete and Partington coming into the squad, while Jarrod Sammut replaced Jake Shorrocks on the bench - though the Aussie didn't get on.
Wigan needed a late drop-goal to win this fixture last year and on the stroke of half-time, a one-pointer from Sam Powell nudged them into an 11-8 lead.
In their first visit to Headingley since its redevelopment, the visitors went behind in the 16th minute when Liam Sutcliffe struck a penalty. By then, the Warriors' line-defence had already been tested following Richie Myler's piercing break.
Wigan got into their groove and after Clubb had a try ruled out by the video referee, they went ahead midway through the first-half when Oliver Gildart turned a tiny gap into an opportunity, swerving and accelerating away from bright talent Harry Newman to score.
Hankinson, kicking in place of Hardaker, did well to nail the touchline conversion to set the tone for his evening.
And with Leeds' discipline letting them down more than their sloppiness, the centre added two penalties to make it 10-2.
The Rhinos, though, closed the gap when Hurrell thundered down the right - Hankinson did well to limit the damage he inflicted - before Adam Cuthbertson muscled over. Sutcliffe's conversion cut the margin to two points before Powell - drop-goal hero at Hull KR five days earlier - struck a one-pointer.
Lam had challenged his players to ensure there was no dip early in the second-half, but yet again they lapsed.
Two handling mistakes, without any pressure, played into the hands of Leeds, who went back in front when Trent Merrin angled to cross far too easily. With Sutcliffe off the pitch injured, Tui Lolohea slotted the conversion to make it 14-11.
Roared on by a vocal following, they pressed the line, broke the Wigan defence, forced errors and approached the hour-mark it needed a big play from Joe Burgess to defuse a teasing kick and snap Leeds' ascendancy.
From that position, they worked their way back into the wrestle and after forcing a repeat set, an improvised attack eventually led to Liam Farrell crabbing across the line and sending Partington charging over for his first try for the club. Hankinson maintained his perfect strike rate to put them 17-14 in front.
It set up a tense final quarter. Leeds enjoyed the better field position and successive errors, by Farrell and Marshall, eventually led to Merrin driving over - only to have a try ruled out by the video referee.
Wigan looked as if they needed energy and a spark, yet Aussie livewire Jarrod Sammut remained on the bench as - with minutes to go - they went chasing a try which would tighten their grip on the contest.
They eventually got it - in balmy circumstances, thanks to Clubb.
Wigan head to Huddersfield next week before returning home with matches against Salford and Hull KR.
Leeds: Lolohea; Briscoe, Newman, Hurrell, Handley; Sutcliffe, Myler; Seumanufagai, Dwyer, Singleton, Watkins, Ferres, Merris. Subs: Oledzki, Smith, Donaldson, Cuthbertson.
Wigan: Sarginson; Marshall, Hankinson, Gildart, Burgess; Williams, Leuluai; Clubb, Powell, Navarrete, Isa, Farrell, O'Loughlin. Subs: Bullock, Partington, Sammut, Smithies.
Referee: Chris Kendall