Motherwell won their fifth successive league game to leave bottom side St Mirren three points adrift at the foot of the Scottish Premiership.
Jake Hastie rocketed home the opening goal - his third in two matches - with a stunning 20-yard drive 10 minutes in.
Paul McGinn's fine looping header levelled for St Mirren with 16 to play.
But just three minutes later, midfielder Allan Campbell glanced a cross into the net to consign the hosts to a sixth straight league defeat.
Second-bottom Dundee drew and 10th-placed Hamilton Academical beat St Johnstone, meaning Oran Kearney's side lost ground in the race to stay up.
Motherwell moved Hibernian, who lost to Celtic, into seventh place with McGinn's goal the first the Lanarkshire side have conceded in four matches.
The first real inspiration came from teenager Hastie, who reinforced his promise with a wonderful opener to follow his double against Livingston on Saturday.
He gathered on the right, burst inside a couple of defenders and thumped a fantastic shot high past Vaclav Hladky. Truly outstanding.
Kearney decided to withdraw defender Jack Baird for attacker Kyle McAllister. Baird showed his fury at his manager - not an encouraging sign for a team embroiled in a relegation scrap.
However, the move nearly paid off. Anders Dreyer saw his effort superbly saved by Mark Gillespie and McAllister then fired over from a good position.
The home side had a more promising spark. In contrast, Motherwell looked content to counter.
They almost doubled the lead from that source when they broke downfield and Curtis Main somehow fluffed his lines from six yards before missing a further two chances.
His side paid the price. Dreyer crossed, McGinn rose and arced his header into the away net, giving the St Mirren supporters an enormous lift.
It was swiftly punctured as Stephen Robinson's side flew up the left, the ball arrowed into the box perfectly for Campbell, who bulleted a header home to preserve Motherwell's winning run.
Home wins are precious when you are fighting for survival but St Mirren's record in Paisley is grim, with only two victories here all season.
Conceding so promptly after drawing level could savagely undermine their confidence. With their next two league fixtures at Hearts and Aberdeen - following a Scottish Cup tie against Dundee United - something has to click quickly.
Motherwell have enjoyed something of a January resurgence in the league. Winning seems normal now.
This wasn't their best performance but they are working for each other and in Hastie they have unearthed another gem, like 20-year-old Campbell and fellow teen David Turnbull alongside him.
It was more than just that, though. They showed great character to respond when pulled back. These are encouraging weeks.
St Mirren manager Oran Kearney on Baird's reaction: "Emotions were running high. It was purely tactical. I felt we had to make that change straight away to make sure we stayed in the game.
"We were disappointed with the start, we deservedly got our goal, it lifts the crowd and we expect a grandstand finish. Our goal seemed to zap energy from us rather than give us energy."
Motherwell manager Stephen Robinson: "When they scored, we lifted it completely. The substitutes, Carl McHugh and Elliott Frear, who set up the goal, did very well and gave us a little bit more impetus.
"Jake Hastie is a good young boy making his way in the game - let's not get too excited too early. He's a great kid, feet on the ground, and we'll keep pushing and developing him."