The Warriors went into Monday night's game without Man of Steel Sam Tomkins, skipper Sean O'Loughlin and second rower Harrison Hansen with one eye on Saturday's Challenge Cup semi-final against London Broncos.
And they looked to have done enough to earn a share of the spoils with the aid of two tries from England winger Josh Charnley and a monster drop goal from Pat Richards.
But 21-year-old Greenwood had the final say, making up for an earlier blunder when he dropped the ball going for a try, as Saints secured only their fifth win in 11 games at Langtree Park this year to boost their play-off hopes.
In a typical error-strewn game on another balmy evening, Saints dominated the opening quarter and went 12-0 up after 15 minutes thanks to two tries from 20-year-old winger Adam Swift on his first appearance for almost three months.
His first try came from a defensive blunder by Wigan at the scrum, with Francis Meli rolling back the years by drawing two defenders to give Swift a clear run to the line.
The youngster then got on the end of a fine break from full-back Jonny Lomax to score his second and Gareth O'Brien kicked his second awkward conversion to put Saints into a 12-0 lead.
Half-backs Blake Green and Matty Smith toiled to get Wigan back in the game and they eventually found the craft to pierce Saints' splendid defence.
Green and Liam Farrell combined to get left winger Richards over on 24 minutes and right winger Charnley pounced for his first try after Swift dropped Smith's high hick.
Richards was wide with both conversion attempts to leave his side trailing 12-8 at the break but they were soon in front for the first time thanks in no small part to the efforts of Ryan Hampshire, the 18-year-old understudy to Sam Tomkins.
First the teenager got back to dislodge the ball from the grasp of Greenwood as he attempted to cross for a try and then linked decisively in attack, releasing Charnley with a one-handed flick.
Charnley still had plenty to do but he beat three defenders to produce a clinical finish and take his tally to 98 in 90 appearances for Wigan.
This time Richards added the goal to make it 14-12 but Saints drew level on 54 minutes when Wigan prop Scott Taylor was put on report for a late tackle on O'Brien and Tom Makinson kicked the resulting penalty.
Richards then struck with a 50-metre drop goal to restore his side's lead but that was only the start of a frenetic final quarter.
As Wigan began to lose their discipline, Makinson, who had taken over the goalkicking duties from the injured O'Brien, was twice wide with penalty attempts that would have put his side back in front.
He then gave way to Jordan Turner when Wigan were reduced to 12 men through the sin-binning of Green on 67 minutes and he duly obliged with the penalty to make it 16-15 to the home side.
Just six minutes were left when Smith put over a drop goal, this one from just 30 metres out, to level once more and they were working their way into position for a third when Saints struck the fatal blow.
Makinson ran back Smith's deep kick from his own 20-metre area and found the space to set up the position for Greenwood to go in for the match-winning try, which was converted by Turner.
- Sports & Recreation
- Pat Richards
- Sam Tomkins