Dunfermline were relegated from the Bank of Scotland Premier League in the cruellest of fashions, after a catastrophic goalkeeping mistake by Dorus De Vries and an 89th minute deflected winner from Inverness substitute Rory McAllister saw Caley Thistle secure an undeserved victory over the Pars.
Jim McIntyre's stunning first-half volley gave Dunfermline a thoroughly-deserved lead, only for De Vries to make a complete hash of trying to save Richard Hastings' free kick.
McAllister then struck late on and coupled with St Mirren's 3-2 victory over Motherwell, that was enough to send Dunfermline to the First Division for next season.
The game started at a high tempo, but the first shot which seriously concerned either goalkeeper did not arrive until the 13th minute, when Michael Fraser saw McIntyre's effort from the corner of the penalty area flash just past his near post.
Inverness retaliated with a Craig Dargo snap-shot five minutes later, which came after the striker latched on to Grant Munro's long throw, although De Vries made a comfortable stop.
Graham Bayne then fired wide when well placed, but the away side proceeded to take control of the game and Adam Hammill forced Fraser into tipping a powerful shot over the crossbar following a surging run full of confidence.
Inverness failed to heed that warning though and Dunfermline soon took the lead.
Gary Mason's high ball was flicked into McIntyre's path by Tam McManus and the former Dundee United player lashed a tremendous volley from 12 yards high into the Inverness net.
It was all Dunfermline at this stage, but Inverness almost sprung a surprise on the counter attack two minutes before the break, only for Richie Hart's shot to be saved by De Vries.
The first half finished with Dunfermline on top though, as Hammill once again tested Fraser, this time with a swerving shot that produced a good catch from the Inverness keeper.
The Pars continued in a similar vein following the restart and it did not take them long to create another chance, although it came from an unorthodox source.
McIntyre's cross was almost turned into his own net by Darren Dods, but thankfully for the Inverness captain, Fraser was on hand to spare the defender's blushes with a crucial save.
Tokely was then booked for a late challenge on Jim O'Brien, while McManus threatened for the first time soon after, with a low shot following a neat turn, that was blocked at full stretch by Fraser.
McManus was now full of life and may well have doubled Dunfermline's advantage had it not been for a brave block by Munro.
Given their dominance, it was not as if the Pars needed any help to create chances, but nevertheless Inverness keeper Fraser tried to help the visitors when he made a complete hash of taking a routine catch.
McIntyre was close to latching on to the loose ball, but Tokely was on hand to clear with an unceremonious hack away from goal.
In the 71st minute Barry Wilson was presented with a great chance to equalise when Sol Bamba's header back to De Vries dropped short, but on his weaker left foot the Inverness substitute could only screw a poor shot wide.
In difficult conditions due to the constant drizzle the mistakes continued and six minutes later, Caley Thistle were gifted a goal as De Vries failed to hold Hastings' shot.
The game was now flowing from end to end as Dunfermline were desperate to find a winner and Mason almost obliged when he latched on to McManus' knockdown, but the midfielder could only direct a shot down into the turf and over.
However, in the final minute, McAllister's drive took the most wicked of deflections and with De Vries diving the wrong way, the ball carried into the net and Dunfermline were down.
Teams
Inverness CT Fraser, Tokely, Dods, Munro (McAllister 76),Hastings, Hart, McBain (Sutherland 69), Black,Paatelainen (Wilson 61), Bayne, Dargo.
Subs Not Used: Ridgers, McCaffrey, Duncan, Rankin.
Booked: Tokely.
Goals: Hastings 77, McAllister 89.
Dunfermline De Vries, Shields, Bamba, McGuire, Muirhead,O'Brien (Burchill 81), Mason, Glass (Owen Morrison 81),Hammill (McCunnie 66), McManus, McIntyre.
Subs Not Used: McKenzie, Young, Hamilton, Woods.
Booked: McGuire.
Goals: McIntyre 37.
Dunfermline are relegated
Att: 6,464
Ref: M Ritchie (Scotland).