Lee McCulloch's 71st-minute penalty gave the home side a belated breakthrough, and Jon Daly doubled the lead on 78 minutes before Joshua Falkingham pulled one back to ensure a tense finale.
But Bilel Mohsni pounced in added time to settle an entertaining clash hampered by the wet and freezing conditions.
The hard-fought win maintained Rangers' perfect start to the season in a game which was initially postponed at the request of Gers due to international call-ups.
McCulloch earned the penalty he converted after he was brought down in the box by Jordan Moore, who was sent off for his challenge by Stevie O'Reilly.
Daly then nodded home a pinpoint cross from Sebastien Foure to notch his 15th goal of the season.
The visitors halved the deficit in the 81st minute when Falkingham slammed home from close range after Cammy Bell could only parry an initial shot.
But Ally McCoist's side made it 11 wins from 11 games when the Dunfermline defence failed to clear a corner and Mohsni belted home the loose ball.
However, McCoist could face a number of injury headaches after McCulloch required lengthy treatment on a head wound, while Andy Little was carried off on a stretcher wearing a neck brace and Richard Foster also limped off.