Dundee started well and with two minutes played Steve Lovell's knockdown at the back post set up David Mackay for a shooting opportunity but the big defender completely missed his kick and Andrius Skerla cleared.
With seven minutes gone Dundee took the lead when Barry Nicholson fired past his own keeper from four yards after good play down the right by Nacho Novo.
With 19 minutes played the home team went 2-0 up when Novo's corner was headed down by Jonay Hernandez and Lovell was on hand to shoot high into the net from close range.
Five minutes later the visitors got themselves back into the game when Stevie Crawford picked out Craig Brewster with a pass into the box and the ex-Dundee United striker scored from eight yards.
Scott Wilson headed just past the post barely a minute into the second half and moments later a great save by Julian Speroni denied Gary Dempsey an equaliser.
Speroni saved Dundee again with 52 minutes gone when he saved a low 30-yard drive by Jason Dair and five minutes later Hernandez cleared a Brewster effort with Sperroni beaten.
A great break by Lovell and Novo saw the latter denied by the fingertips of Marco Ruitenbeek with an hour gone.
Midway through the second half a 25-yard free-kick by Brewster was saved by Speroni and Dundee raced upfield and only a great diving save by Ruitenbeek denied Garry Brady.
The visitors drew level with 73 minutes played when Crawford raced in on goal before rounding Speroni and slotting home from eight yards.
It got worse for the home team when Lee Wilkie received his second yellow of the game for protesting about the visitors' goal and the home team were reduced to ten men.
With seven minutes to go Dunfermline took the lead and all three points when Jason Dair hit a cracking 25-yard drive past Speroni when there seemed little danger to the Dundee goal