Burton O'Brien's 88th-minute strike delivered all three points for Livingston and continued their dominance over beleaguered Aberdeen in the Bank of Scotland Premier League.
The Dons had trailed for much of the game after Colin McMenamin scored early on but thought they had done enough to avoid defeat when, after dominating for most of the second half, Leigh Hinds popped up to equalise with four minutes left.
However, they capitulated in the final moments, allowing late substitutes David Fernandez and O'Brien to combine and steal the points.
There had initially been a doubt over whether the game would take place after a rainstorm swept over Pittodrie, leaving the pitch heavily waterlogged.
Referee Mike McCurry delayed his decision until 40 minutes before kick-off to allow the Dons' backroom and office staff, including general manager David Johnston, to deploy squeegees and forks on the surface to get it into an
acceptable condition.
When play did commence, five minutes behind schedule and on a pitch that was still sodden, it was the visitors who created the first chance.
Jon-Paul McGovern tried to find Fernando Pasquinelli with a chip towards the back post but the South American, who had dropped in behind Michael Hart, could not stretch far enough to make contact.
Aberdeen forced their way up field almost immediately and should have done better in the ninth minute when Markus Heikkinen played a one-two with Hinds on the edge of the penalty area. The Finn had a clear sight of goal, but snatched at his shot and fired wide.
Livi then took the lead in bizarre fashion after 14 minutes, when Jamie McAllister's drilled low cross ricocheted off referee McCurry straight into the
path of Pasquinelli. He dug the ball out from between his feet and teed up McMenamin, who coolly claimed his third Livingston goal of the campaign.
Aberdeen's afternoon took another downward turn on the half-hour mark when Richard Foster limped off and was replaced by David Zdrilic. They almost snatched the equaliser a minute later, however, as Hinds found space on the left and flashed a cross through the penalty area.
Livi were caught square and allowed Paul Sheerin plenty of room at the back post, but the ball zipped off the turf and shot beyond his outstretched leg.
Fortune was on their side again, in the 36th minute, when goalkeeper Roddy McKenzie momentarily lost Hinds' shot in the sun and only saw the ball come to him at the last minute. The ex-Hearts man had to move quickly to prevent a
goal.
Aberdeen should have equalised three minutes into the second half, but once again Heikkinen, from a position identical to the one he missed from earlier in
the game, shot wide of the post.
Fergus Tiernen's good run along the 18-yard line created space for the midfielder, but he never looked confident of scoring and another great chance to get back into the game was spurned.
Livi were walking a tightrope and had to rely on McKenzie again, in the 58th minute, to punch clear after Oscar Rubio made a mistake inside the area and let
Sheerin steal the ball off him.
Visiting boss David Hay clearly sensed that his players' legs were starting to tire after a hectic seven days and brought on O'Brien for McAllister.
Luck certainly went in their favour again when Marvin Andrews fouled Hinds inside the area but McCurry, who had a clear view of the incident, waved for
play to continue. Sheerin claimed the loose ball and had only the goalkeeper to beat, but eventually shot wide.
McKenzie came to Livi's rescue once more, in the 70th minute, when he brilliantly tipped over a Hinds header from point-blank range.
Former Celtic prospect Bryan Prunty, who had struggled to make an impact on the game, hobbled off with 12 minutes remaining and was replaced by youngster Kevin Souter.
The equalising goal, which had seemed inevitable after the Dons' constant stream of chances throughout the second half, finally came with six minutes left.
Hinds saw the goalkeeper brilliantly save his volley from Zdrilic's flick-on - and, at last, got a slice of luck as the ball rolled back to him with the net at
his mercy.
However, the match took a final twist as Livi, who had been on the back foot since the break, regained the lead.
Fernandez, a second-half substitute, sprinted clear of the Dons defence and rolled the ball into the path of O'Brien, who calmly slotted home.
Teams
Aberdeen Preece, Hart, McGuire, Diamond, Morrison, Tiernan,
Heikkinen (Muirhead 67), Sheerin, Hinds, Prunty (Souter 78),
Foster (Zdrilic 30).
Subs Not Used: Esson, Rutkiewicz.
Goals: Hinds 84.
Livingston McKenzie, Rubio, Andrews, Dorado, McNamee,
McLaughlin, Brittain, McGovern, McAllister (O'Brien 61),
Pasquinelli (Lilley 65), McMenamin (Fernandez 67).
Subs Not Used: Main, Snowdon.
Goals: McMenamin 14, O'Brien 87.
Att: 7,477
Ref: M McCurry (Scotland).