After a dominant first-half display had failed to yield a goal for the Fifers, Stephen Husband broke the deadlock early in the second half with a free-kick from 30 yards which found the net with the aid of a deflection. But Airdrie were level within a minute; Liam Coogans curling home a 15-yard shot.
Dunfermline threw everything at Airdrie in the closing stages and were rewarded when Andy Geggan scrambled home the winning goal with just four minutes left.
Stenhousemuir also moved to within two points of the top as they held off a late fightback to beat Arbroath 4-3 at Gayfield.
Bryan Hodge put them ahead only for Lee Erwin to equalise but goals from Sean Higgins, John Gemmell and Sean Dickson had Stenhousemuir in control before Colin Hamilton and Alan Cook pulled back late goals to give them a scare.
Ten-man Brechin City secured an unlikely 2-2 draw at Ayr United thanks to a late strike from Paul McLean. Graham Hay was sent off in 33 minutes for a wild challenge on Michael Moffat and Ayr took full advantage.
Moffat and Michael McGowan both scored before half-time and Ayr would have led by more but for some brilliant goalkeeping from Graeme Smith. Alan Trouten turned the game with a 68th-minute goal for Brechin and then McLean came up with the equaliser.
Stranraer hoisted themselves off the bottom with a 2-0 win over East Fife. Martin Grehan gave them a half-time lead with his sixth goal of the season and Jamie Longworth made sure of the points with another in the second half.