Jim Jefferies' side took the lead after four minutes when Moroccan defender Faissal El Bakhtaoui fired into the far top corner.
Forfar, however, drew level with half-time approaching thanks to James Dale, the English midfielder finding the bottom corner for his first goal since last September.
Dick Campbell's men then pulled ahead on the hour when Gavin Swankie powered a shot past a helpless Ryan Scully.
El Bakhtaoui went from taker to maker, squaring for substitute Stephen Husband to equalise before a Darren Dods own goal made it 3-2 for the visitors in a whirlwind five minutes.
Lawrence Shankland came off the bench to put a flattering gloss on the scoreline at the end, firing in Danny Grainger's cross.
At the other end, Airdrie climbed off the foot of the table with a 2-1 win at home to Brechin.
Arbroath replaced Airdrie as League One's basement club after drawing 1-1 at Stranraer, who are now third above Ayr on goal difference.
East Fife, without a win in three games under Gary Naysmith, stay third bottom after drawing 1-1 at Stenhousemuir.