Goals from Nicky Clark, Ian Black and Nicky Law, plus Lee McCulloch’s second-half penalty moved the Glasgow giants back to the top of the table but Hearts will reclaim the lead if they beat Dumbarton on Saturday.
Clark opened the scoring in the 16th minute when he out-jumped Ross Perry to glance home Fraser Aird’s cross from 12 yards out.
Black doubled their lead seven minutes before the break as his 20-yard strike beat Ross Laidlaw with the aid of a massive deflection off Paul Watson.
Rangers’ second goal was a real sickener for the hosts but the League One champions did not let up and netted again 60 seconds later as Macleod fed Law inside the box. The Englishman took one touch before bending a right-footed finish into the top corner.
The away support had lapped up a much-improved display from their team in the first half but did not let the Rangers directors off the leash after the interval as they bellowed “Sack the board, sack the board”.
Their attention was turned back to the on-field action though as Kris Boyd latched on to Macleod’s flick on before screwing wide.
The former Scotland frontman was twice denied by saves from Laidlaw before Wallace was brought down in the box by Grant Anderson.
Rangers fans made it clear who they wanted to take the spot-kick, but Boyd was left disappointed again as skipper McCulloch pulled rank before slotting home from 12 yards with 22 minutes remaining.