Dunfermline struck three times in the final 12 minutes to snatch a dramatic 3-3 draw at Dundee, for whom Charlie Adam scored a wonder goal and set up two others.
The Pars came into the match looking to bounce back from their first Championship defeat of the season last weekend, as well as being knocked out of the Betfred Cup quarter-finals on penalties in midweek.
But they looked set to be left empty-handed again as Dundee established a 3-0 lead through goals from Adam, Osman Sow and Liam Fontaine, only for Declan McManus (two) and Paul Watson to leave the Dens Park outfit stunned.
Dundee had already gone close through Jordan McGhee and Christie Elliott when Adam smashed them ahead in the 35th minute with a 30-yard thunderbolt which left Owain Fon Williams with no chance.
The former Liverpool and Rangers midfielder then twice turned provider as Dundee increased their lead in the second half, his free-kick being headed home by Sow before taking the corner from which Fontaine scored.
Adam was substituted soon after Fontaine's 70th-minute effort, but the points were not as secure as Dundee may have felt.
Watson's 78th-minute header gave Dunfermline a lifeline before McManus further reduced the arrears with a penalty four minutes later.
Dundee still looked set to hold on, but there was a late twist as McManus fired home a superb 25-yard free-kick in stoppage time to cap a remarkable comeback.