Rangers returned to winning ways and got their Champions League exit out of the system, but they had to fight all the way against a resilient Hearts side.
The goal that proved to be the winner came four minutes from the end and was an absolute nightmare for Hearts keeper Eduardas Kurskis, who will probably be credited with an unwanted own goal.
A short free-kick was played to David Weir and he set the ball into the mix inside the Hearts box, Lee McCulloch scuffed effort looked to have been collected easily by Kurskis, but he managed to drop the ball over the line and hand all three points to Rangers.
The home side, playing an unfamiliar 4-3-3, started brightly and Charlie Adam unleashed a terrific swerving shot from 25 yards after only four minutes that had beaten the keeper, but crashed off the bar, the rebound falling kindly to Kris Boyd but the usually lethal striker shot wide.
Two minutes later Kurskis made a great save to deny Steven Naismith, after he had gathered McCulloch's flick-on and sent a good shot towards goal from close range.
In eleven minutes great Rangers play on the right sent Alan Hutton rampaging forward and his cross found Naismith well positioned inside the box, but he shot wide of the target.
Rangers went ahead in 17 minutes when Lee McCulloch burst on to the ball after a mistake by Jose Goncalves after a fine Adam pass and Scotland star McCulloch calmly slotted the ball past the helpless keeper.
Midway through the half McCulloch thought he had grabbed a second from an Adam free-kick but his shot was blocked.
Hearts' first effort on goal came five minutes before half time, when Andrew Driver sent his right-foot shot wide after Rangers defender Carlos Cuellar could only half clear a Goncalves cross.
Hearts made a half-time substitution when Saulius Mikoliunas was replaced by Kestutis Ivaskevicius and the change saw them push forward from the early stages of the second half.
With only five minutes gone Andrius Velicka received a fine pass from Driver but dragged his 20-yard shot wide, with Rangers keeper Allan McGregor scrambling across his goal.
Moments later Rangers won a free-kick after a foul on Barry Ferguson and Adam whipped in a dangerous cross to the head of Boyd, but he glanced his header just wide.
Hearts grabbed an equaliser after 55 minutes, through Velicka, who got in between Cuellar and Weir to meet a Driver free-kick and the Lithuanian powered his effort beyond the helpless McGregor.
Two minutes later Calum Elliot broke on the right after a superb Velicka pass had sent the young Scot clear and his great ball into the area almost found Driver, but Cuellar and McGregor between them scrambled the ball away.
Midway through the second half Driver mis-kicked in front of goal, but almost made amends in Hearts' next attack. But his terrific 25-yard shot produced a great save from McGregor as he pushed the ball over.
Just after Rangers' second goal Ferguson had the chance to add to the score, but shot wide from inside the box after a good cross from Jean-Claude Darcheville.