Rangers closed the gap on Celtic at the top of the SPL table to one point and set up what will almost certainly be a title decider against their Old Firm rivals next Saturday.
Hearts looked more threatening in the first half, but it was Rangers who snatched the first goal just before half-time through their former player Andrius Velicka.
It took a late goal by top scorer Kris Boyd before Ranger knew the points were safe.
The visitors threatened early on when Mike Tullberg's shot from Andrew Driver's cross was parried away by Neil Alexander.
Rangers then had a chance but Boyd drove his free-kick into the defensive wall.
As Rangers stepped up the pressure, Steven Whittaker's drive drifted narrowly wide.
A free-kick by Steven Smith beat the wall but Marian Kello helped the ball comfortably over his bar.
Hearts then broke when Lee McCulloch slipped and allowed Bruno Aguiar to advance unchecked, but his shot was well saved by Neil Alexander diving to his left.
A poor clearance by Kello presented a chance for Boyd who did well to lob the keeper only to see his effort come back off the bar.
Rangers made their breakthrough from their first corner of the match. Smith's in-swinger to the back post was headed back across goal by Boyd for Velicka to stab home from six yards.
At the start of the second half, McCulloch did well to head clear a driven cross into the danger zone.
At the other end, Boyd laid the ball of superbly to Steven Davis but he could only shoot weakly at Kello.
Whitaker then appeared to clip Calum Elliot's heels in the penalty box but the referee deemed it accidental.
Rangers nearly took advantage of this break when Pedro Mendes put Davis through but again Kello blocked his shot.
But Rangers wrapped up the points when Davis' pass across the area reached substitute Kenny Miller and Boyd bundled the ball home from close range.