Livingston's relegation from the Bank of Scotland Premier League was all but confirmed as Dunfermline twice came from behind before claiming a 3-2 win at East End Park.
John Robertson's side had looked set to take the battle to beat the drop to the last kick of the campaign after a wonder-strike from Colin Healy had given them a 2-1 lead over their fellow strugglers midway through the second half.
Victory would have moved them to within three points of their nervous hosts, but the Pars fought back to tie the score through Mark Burchill, who had earlier cancelled out Richard Brittain's penalty opener from the spot at the other end.
Burchill then set up Noel Hunt for the winner five minutes before the end, although the former Celtic striker appeared to claim the strike himself.
However, the winner was shrouded in controversy with claims of handball by Hunt.
The result puts Jim Leishman's side nine points ahead with just three games left and the Pars' vastly superior goal difference means Livi have no realistic hope of emulating last season's final-day escape.
Livi had even arrived late, having been hampered by problems on the Forth Road Bridge, but shrugged that off to start brightly and take a deserved lead in the ninth minute.
Noel Whelan had fired an early effort off target before Allan Walker headed over and the home side had shown nothing in reply when referee Stuart Dougal awarded his first penalty of the day.
Greg Ross, who had only just returned from suspension, was the man penalised for a challenge on Wes Hoolahan on the edge of the box on the right and the home fans' claims that the Irishman had gone down too easily appeared to have some substance.
That was of no concern to Brittain however and he calmly slotted past Allan McGregor to give Livi the start their noisy band of followers craved.
Ross was perhaps lucky to escape a booking for a challenge on Hoolahan which left the midfielder hopping, but referee Dougal did show a yellow card on the half-hour mark when David Mackay went in too hard on Scott Muirhead.
The Pars had at last began to look dangerous by this point and Hunt sent a drive fizzing just wide after Scott Wilson had seen a drive blocked by Greg Strong.
Muirhead had been a pre-match injury concern and had to leave for treatment in the 35th minute before returning to test Livi goalkeeper Roddy McKenzie with a well-struck long-ranger.
McKenzie was equal to that but soon become the man in the spotlight for the second penalty award, with Burchill having been clipped as he tried to nip in ahead of Harald Pinxten.
The former Celtic striker made no mistake from 12 yards to record his 13th goal of the season and the breakthrough was the start of a strong finish to the half by the home side.
Wilson sent a diving header just wide from a free-kick before McKenzie had to tip a well-struck drive from Muirhead round a post.
The corner caused Livi considerable alarm too as it found its way to Burchill at the back post, where the former Scotland man fired across goal and inches wide.
Ross saw an effort deflected behind as Livi clung on until the half time whistle and used the break to make a change up front, with Steven Hislop replacing Sam Morrow and the newcomer scooped a fair chance over from 12 yards after Hoolahan had fired in a low cross from the right.
Strong was booked just before the hour mark for a body-check on Aaron Labonte but Livi turned the free-kick into a counter-attack move that saw Healy fire wide at the other end.
Both sides looked as though they intended to press for a winner and Healy fired Livi ahead in the 63rd minute with a fine 20-yard effort which beat McGregor and went in off the goalkeeper's right-hand post.
Hoolahan had again been involved by winning a throw-in which he fed to the ex-Celtic man, who shrugged off Ross' challenge before firing in his perfectly-placed, curling effort.
The home side needed a response and almost found it from the recalled Pole Bartosz Tarachulski, who was sent clear in search of his first Pars' goal.
But the striker could not find it as McKenzie came off his line to block but the ball fell perfectly for Burchill to locate the empty net calmly.
The final few minutes were far from calm as Hunt was booked for chopping down Hoolahan.
The Irishman then arrived at the back post in the 85th minute to force home the winner after Burchill had headed the ball across the danger zone.
The away side protested that there had been an infringement, but Livi knew then they were doomed and Robertson also exchanged words with referee Dougal.
Teams:
Dunfermline McGregor, Labonte, Shields, Scott Wilson, Thomson,Ross, Mason, Muirhead (Daquin 73), Hunt (Tod 90), Burchill,Tarachulski.
Subs Not Used: Halliwell, Phinn, Iain Campbell, Andy Campbell,
Camano.
Booked: Hunt.
Goals: Burchill 38 pen, 78, Hunt 85.
Livingston McKenzie, McNamee (Tierney 87), Pinxten, Strong,Mackay, Brittain, Healy, Walker, Hoolahan, Morrow (Hislop 45),Whelan.
Subs Not Used: Woods, Adams, Scott, Miller, Dorrans.
Booked: Mackay, Strong.
Goals: Brittain 9 pen, Healy 63.
Ref: S Dougal (Scotland).