Ryan Wallace gave the hosts the lead as early as the third minute when he found the target from close range and Ewan Moyes doubled their advantage by scoring an own goal midway through the first half.
Things went from bad to worse for Brechin just before the hour mark when Stuart Anderson was dismissed, but Paul McLean gave the visitors some late hopes when he turned in Andy Jackson's pass from inside the home team's box in the 80th minute.
However, Wallace secured the points for Dunfermline with three minutes of normal time remaining on the clock, latching on to Allan Smith's pass and slamming home from the left side of the box with his left foot.
In what proved to be a topsy-turvy contest at Somerset Park that had three penalties successfully converted, Kevin Kyle's header from close range after meeting Anthony Marenghi's delivery in the 85th minute was the winning goal.
Results in full: Ayr 4-3 Stenhousemuir, Dunfermline 3-1 Brechin, Forfar 2-0 East Fife, Stranraer 3-1 Airdrieonians