MacLeod drifted into the box to meet a dipping Fraser Aird cross and plant his header beyond the diving Alan Mannus with four minutes remaining.
However, Rangers were without the usual noisy backing of their home support as many fans boycotted the match.
There were just 13,023 inside the ground with around 100 members of the Sons of Struth group protested outside the front door on Edmiston Drive.
They were unhappy about the club’s decision to accept a £2m loan from controversial Newcastle United owner Ashley – a move which effectively hands him control of the club.
His two right-hand men, Derek Llambias and Sports Direct Head of Brands Barry Leach, watched the match from the directors box after both were brought in as consultants to the board.
On the field, the Saints almost took an early lead when a low cutback from the right flank by Michael O’Halloran spun in front of Simon Lappin eight yards out but Ricky Foster slid across to block his net-bound shot.
Rangers responded 10 minutes later as Macleod burst forward from his own half and released Kris Boyd, but the advancing Mannus used a foot to block the striker’s shot from inside the penalty area.
But the Championship side survived a scare three minutes before the break when Lee Croft latched on to a poor pass from Lee Wallace and chipped a cross back from the goal-line but Frazer Wright headed over the bar.
Foster again rescued Rangers in first half stoppage-time as he got in front of Brian Graham to nod the ball over his own bar from a dangerous O’Halloran delivery across the face of goal.
Macleod created another chance for Boyd inside the opening 90 seconds after the break but his snap-shot came off the heel of his former Kilmarnock team-mate Wright and spun wide for a corner.
A minute later Steve Simonsen turned O’Halloran’s low angled shot wide after he raced into the box leaving Foster and Lee McCulloch trailing.
The keeper was carried off a few minutes later wearning a neck brace when he cracked his face against the post saving Graham’s downward header.
Substitute keeper Lee Robinson raced out of his box to clear a through pass but was beaten for pace by O’Halloran, but the ball spun back on the striker and Darren McGregor booted it clear.