Youngster Chris Burke was the home side's hero as Rangers struggled to a narrow victory.
After falling behind to an early Andy Kirk goal, Shota Arveladze levelled matters before Burke netted from close range just after the interval with what proved to be the winning goal.
After two successive defeats Rangers confidence was low and the loss of an early goal did not help. Michael Ball conceded possession carelessly and Fernando Ricksen headed Robert Sloan's first corner narrowly passed his own post.
From the next corner Arveladze cleared off the line from Kevin McKenna before Hearts finally scored from the third corner.
Sloan's cross eventually reached Kirk through a crowd of players and the striker netted from close range.
Rangers had earlier been denied when Michael Mols freed himself from Patrick Kisnorbo only for referee Hugh Dallas to order a free-kick.
The Dutch striker then volleyed over a Ricksen cross before Rangers equalised.
From Ricksen's long clearance, Ball controlled well and though Craig Gordon bravely blocked his shot, the Hearts keeper was helpless to prevent Arveladze heading home the rebound.
Gordon brilliantly parried Peter Lovenkrands' perfect header before saving from Mols.
However the visitors were by no means lacking confidence and Stefan Klos threw himself to block Sloan's shot before the ever dangerous McKenna headed narrowly wide.
Rangers should have gone ahead just before half time, but from point-blank range Arveladze headed straight at Gordon before Lovenkrands screwed his shot wide.
The Ibrox side made the breakthrough early in the second half. Lovenkrands' astute pass released Mols, whose left-foot cross was swept into the net by Burke.
Arveladze then squandered a great opportunity after good work by Burke before Hearts threatened again. McKenna 's header from Paul Hartley's cross looked netbound before Klos somehow got across.
In the nervous final ten minutes Klos did well to cut out a Robbie Neilson cross before making good saves from sub Graham Weir and Neilson as Rangers hung for a victory which reduced their deficit to Celtic to five points.