Stephen Kenny celebrated his first SPL win as Dunfermline boss as the Pars gave themselves a survival lifeline.
The shock 3-1 win at Inverness means they are now six points behind St Mirren, who have a game in hand.
The Irishman enjoyed a perfect St Patrick's Day reason for celebration with their first ever SPL success over the Highlanders.
The Fifers travelled north on Friday as the importance of each match grows each passing week in their bid to stay in the top-flight.
For the hosts, their chances of beating Hibs or Kilmarnock in the race for sixth place all but vanished after last week's reversal at Killie, so Charlie Christie's men are simply aiming to finish the term with a flourish.
Inverness welcomed back striker Craig Dargo to the squad after being sidelined with a shoulder injury for two months.
Dunfermline came close on ten minutes when only a fine Stuart McCaffrey intervention denied Adam Hammill as he broke through on goal.
At the other end, keeper Dorus de Vries got down well to save a Graham Bayne drive after Barry Wilson's free-kick broke loose in the area.
The deadlock was broken on 23 minutes when a goalmouth scramble saw the ball being teed up for Markus Paatelainen and he made no mistake from 12 yards.
The Pars tried to hit back moments later but goalkeeper Michael Fraser was equal to the 20-yard free-kick from James O'Brien.
Ian Black almost doubled the lead but de Vries got down well to block his shot.
Just before the break, de Vries then pushed over the bar a net-bound dipping effort from Barry Wilson from near the right touchline.
Kenny's men scored a shock leveller just three minutes into the second half when a fierce volley was driven home just inside area by Stephen Glass after a cut-back from O'Brien.
The Fifers continued to threaten and stole into the lead when O'Brien's delivery was knocked into the net by Jim McIntyre.
Victory was sealed when Hammill was felled by Richard Hastings. To everyone's surprise, referee Chris Boyle pointed to the spot when a free-kick looked the likely outcome. From the penalty, Glass slammed home his second of the day for a 3-1 victory.
In stoppage time, Tom McManus was shown a straight red card after a flashpoint with Black after the Inverness man appeared to trip him.