Kevin McBride's 90th-minute goal snatched a dramatic win for Motherwell at Almondvale and sent Livingston back to the foot of the SPL table.
Livi midfielder Richard Brittain was the key player in the first half, playing a vital role in both goals.
Richie Foran latched onto his stray pass to put Motherwell in front on the half-hour mark, but minutes later Harald Pinxten headed home his cross.
But at the death, McBride's drive from the edge of the box sealed the win.
Motherwell had the better of the early exchanges, with Livingston keeper Roddy McKenzie doing well to keep out Phil O'Donnell's close-range effort and a Jim Hamilton header.
But when the opening goal came, it was courtesy of a blunder by Brittain.
Foran picked up the ball in the centre circle and shrugged off the attentions of Allan Walker to keep his composure and shoot under McKenzie.
But it was only a short-lived lead, as Motherwell failed to clear Robert Snodgrass's corner properly, and Brittain was on hand to set up Pinxten to level the scores.
The qualify of the game dipped after the break due to a series of unforced errors, with play mainly being confined to the middle of the pitch and neither goalkeeper seeing much of the ball.
But just as it looked like Livingston were in line for a precious point, McBride struck in the 90th minutes, making room for himself on the edge of the area before drilling home a dramatic winner.