Rangers eventually secured the victory they so desperately needed to keep in touch with Hearts. It took a glancing header from Greek defender Sotirios Kyrgiakos 20 minutes from time to ease the home side's worries.
Indeed if it had not been for two superb saves by Stefan Klos at the start and end of the second-half, this could have been a very embarrassing afternoon for Rangers.
Klos was back because of illness to regular keeper Ronald Watterrus, and the German keeper produced a couple of superb saves to keep Rangers in the game.
Despite incessant pressure in the first half, Rangers could not find a way through Dunfermline's defence. From Dado Prso's overhead kick, keeper Bryn Halliwell did well to block Kris Boyd's close-range effort.
Prso unleashed a powerful 25-yard shot which struck the post before Boyd hit the rebound wide.
It looked only a matter of time before Rangers took the lead, and they should have done so when Steven Smith put Barry Ferguson through but Halliwell again came to Dunfermline's rescue.
The Dunfermline keeper produced another fine save to touch over Chris Burke's volley.
Klos made a superb block at the start of the second-half from Gary Mason after Lee Makel's pass had opened up the Rangers' rearguard.
Rangers responded with a Thomas Buffel volley from Prso's pass which Halliwell touched over. Then substitute Jamie McCunnie cleared a Prso header off the line.
Rangers finally made the breakthrough when substitute Peter Lovenkrands outpaced Scott M Thomson down the right wing before sending in a cross which Kyrgiakos headed in at the near post.
Klos produced an outstanding save in injury time when he somehow clawed Andy Tod's overhead effort over the bar.