Brian McLean kept alive Motherwell's hopes of a top-six finish in the Bank of Scotland Premier League with an 89th-minute winner at Fir Park - a result which moves Livingston one step closer to relegation.
Former Livi man Jim Hamilton headed home Phil O'Donnell's clipped cross to give the dominant home side the lead in the 40th minute but Noel Whelan pounced for an equaliser for John Robertson's outfit on 75.
Central defender McLean, on loan from Rangers and who also scored last weekend, finished with a striker's technique to break Livi hearts and consign them to their 13th consecutive defeat in the league.
Terry Butcher's side must now defeat Rangers at Ibrox next week and hope Aberdeen - who take on Hibs - do not win at Easter Road if they are to land a top-six place.
Despite their miserable run this year Livi started brightly and in the third minute Wes Hoolahan twisted and turned in the box before crossing for the recalled Steve Hislop, whose sweetly-struck effort brought a fine save from Graeme Smith - who was back in goal at the expense of Colin Meldrum.
The home side soon got into their stride after that though, and, with Alan McCormack pulling the strings in midfield, they began probing for an opening.
Their first opportunity arrived in the 10th minute when Richie Foran squeezed a cross out on the left of the box and Hamilton outmuscled Greg Strong to head just inches over.
Three minutes later former Motherwell defender Strong was deceived by Well hitman Scott McDonald 10 yards from goal and referee Eddie Smith had no hesitation in pointing to the spot.
Foran stepped up to take the penalty but his weak side-footed effort was saved by Roddy McKenzie and the Irishman failed to make amends when he scuffed his follow-up attempt.
Motherwell kept pressing for the opener and McDonald looked poised to provide it when he raced clear of the ponderous Harald Pinxten, rounded McKenzie and rolled the ball towards the empty goal - only to see the Belgian defender redeem himself by clearing off his own line.
Livi were forced into a change on the half-hour mark when Derek Adams limped off to be replaced by former Celtic midfielder Colin Healy.
The substitution did not allow the visitors to get a foothold in the game though and on 34 Martyn Corrigan's chipped cross was headed onto the roof of the net by Australia striker McDonald.
A minute later McDonald, usually so assured in front of goal, squandered another chance when he sprinted clear of Pinxten - in the side in place of the suspended Manu Dorado - and Strong but dragged his shot wide.
But Motherwell finally got the goal they had threatened all half when former Lions forward Hamilton headed home Phil O'Donnell's clipped cross with aplomb at the back post in the 40th minute.
Foran nearly made it 2-0 on the stroke of half-time when he hit the bar with a header after the Livi defence failed to pick him up.
Robertson made two changes at the break in a bid to give Livi some impetus, bringing on Gary Miller and former Aberdeen striker Whelan for Hoolahan and the hapless Pinxten.
It did little to affect the momentum though and Whelan's only early contribution was to be booked for a clash with Corrigan.
His presence did give the Motherwell defenders something to think about though and Corrigan's firm back-header forced Smith to acrobatically claw the ball away from danger in the 63rd minute.
Three minutes later Motherwell would have doubled their advantage had McKenzie not brilliantly saved O'Donnell's thunderbolt.
Livi strung their best move of the match together in the 75th minute when Richard Brittain's cross was knocked back across goal by Hislop and Whelan was there to expertly flick home the equaliser from five yards.
Butcher immediately reacted to that setback when he replaced Kevin McBride with winger Jim Paterson and then a couple of minutes later withdrawing Hamilton in favour of David Clarkson.
It almost had the desired effect on 82 when a fine passing move gave McCormack the chance to shoot from close range but McKenzie bravely smothered the danger.
But Motherwell grabbed the winner they deserved in the 89th minute when defender McLean swivelled cleverly in the box and fired magnificently beyond McKenzie.
Teams
Motherwell Graeme Smith, Corrigan, Craigan, McLean, Hammell,McBride (Paterson 78), McCormack, O'Donnell, Foran,Hamilton (Clarkson 81), McDonald.
Subs Not Used: Meldrum, Kerr, Leitch, McGarry, Kinniburgh.
Goals: Hamilton 40, McLean 90.
Livingston McKenzie, Mackay, Strong, Pinxten (Miller 45),Brittain, Hoolahan (Whelan 45), Adams (Healy 31), Walker,Tierney, Morrow, Hislop.
Subs Not Used: Roy, Snodgrass, Dorrans, Scott.
Booked: Whelan, McKenzie.
Goals: Whelan 76.
Att: 4,458
Ref: E Smith (Scotland).