An injury-time penalty from Darren Young earned Dunfermline a dramatic point at East End Park.
The home side were reduced to 10 men when Lee Makel was sent off midway through the second half for handling a Marvin Andrews header on the line.
But Dunfermline refused to give up and Sotirios Kyrgiakos was sent off in injury-time after two bookings in quick succession, the second for pulling back Andy Tod. It gave the Pars a penalty and Young kept his cool to slot home the equaliser.
Dunfermline had earlier broken the deadlock after 16 minutes when Noel Hunt's cross was headed in at close-range from Tod.
Peter Lovenkrands equalised six minutes later after a cleverly-worked free-kick saw the Dane curl a 20-yard shot high into the net.
Rangers' joy was short-lived as Dunfermline went ahead again within a minute, when Darren Young sent Mark Burchill scampering clear and he tucked the ball past Ronald Waterreus and into the net off the inside of the post.
Thomas Buffel had a good chance to level before the interval but could only direct his shot at Bryn Halliwell.
Steven Thompson was denied by a reaction save from Halliwell early in the second half as Rangers pressed for the equaliser, while Greg Ross should have done better at the other end than send a tame header at Waterreus shortly afterwards.
Lovenkrands levelled from the penalty spot after Makel had handled Andrews' header on the line - earning the Dunfermline player a red card.
Chris Burke then scored with a great solo goal to rub salt in the wound as the game turned in a matter of minutes.
But, just when it looked as if Rangers would hold on, Kyrgiakos picked up his two yellow cards and gave away a penalty for Young to have the final say.