Graeme Murty resisted the urge to do a celebratory handstand, but there was no hiding the relief of the Rangers interim manager and most of the 46,800 souls inside Ibrox as he picked up his first league win at the third attempt in the most dramatic fashion.

Barrie McKay hit the opener against a lacklustre St Johnstone outfit midway through the first half before Martyn Waghorn headed the second just after the break.

The Saints then belatedly came alive as substitute David Wotherspoon dragged them back into it before Rob Kiernan picked up a straight red card with a little over 10 minutes left to add to the tension in the stands.

Read more: Graeme Murty: Last-gasp Rangers heroics show players DO care about club

Steven Anderson thought he had then won an unlikely point with the equaliser three minutes from the end, but there was still time for the outstanding Emerson Hyndman to pop up and win it for Rangers in injury-time to move them within six points of second-placed Aberdeen.

Murty made two changes to the side that lost to Inverness last Friday night, with Clint Hill recovering from whiplash to take his place in defence at the expense of Danny Wilson, and Jason Holt coming in for Andy Halliday.

The reshuffle seemed to have the desired effect as Rangers started on the front foot, almost taking the lead in the opening minutes as Waghorn found space on the left and saw his shot blocked only for Hyndman to crack an effort just past.

There were signs of nervousness from the home side though, and Jon Toral embodied that uneasy feeling as he passed the ball straight to Steven MacLean to present him with a shooting opportunity, but he blasted over from 25 yards.

Rangers could have done with a goal to settle themselves down, and they should have had it when James Tavernier curled in a free-kick onto the head of Toral, but the midfielder’s glanced effort bounced safely past.

The Ibrox men were looking likely now though, and Hyndman bent a shot just past from the edge of the area after good set up play by McKay.

The running of former Ger Richard Foster were keeping the home defence honest though as he twice threatened to break through from his berth on the right before being crowded out.

Read more: Graeme Murty: Last-gasp Rangers heroics show players DO care about club

It would be Rangers who would deservedly get the all-important opener midway though, and it was the impressive Hyndman who again caused all the problems for the St Johnstone defence.

The American danced his way into the area, side-stepping three challenges before his shot was blocked to Lee Wallace, whose shot in turn was charged down by Liam Craig.

The ball fell kindly for McKay though, who picked his spot well from the edge of the box to steer the ball into Zander Clark’s bottom right-hand corner for just his third league goal of the season.

The Saints thought they had levelled straight away, or at least, their pocket of fans did, as they celebrated wildly despite Blair Alston’s snap-shot from 20 yards flying just the wrong side of the post and rebounding back into the side-netting.

Despite the attacking menace of Rangers they still looked shaky at the back, with clearances too often lacking the required conviction and St Johnstone players finding space a little too easily, as Foster found when heading weakly at Wes Foderingham after being picked out by a great cross from Brian Easton.

Waghorn then showed good feet as he feigned his way past two despairing challenges to give himself a sight of goal, but Clark stood tall to deny him with a decent save.

Read more: Graeme Murty: Last-gasp Rangers heroics show players DO care about club

McKay was putting on something of an exhibition down the left, and having earlier produced a glorious turn that sent Keith Watson half-way down the tunnel he then nutmegged Foster to get into a good position, but Hyndman just failed to latch onto his cross to the far post.

Jason Holt almost capped off a satisfactory first-half for the light blues as his long-range curler looked destined for the top corner, but Clark did well to get up and claw the ball to safety.

How St Johnstone weren’t level just after the restart only their midfielder Craig knows, as Watson got to the line and clipped a cross perfectly into his path, plum centre of goal. He only had to hit the target from six yards, but somehow steered the ball wide.

And boy was he regretting it just a minute or so later, as Waghorn showed him how it should be done.

Kenny Miller picked the ball up on the right and curled a ball into the area that his strike partner cleverly glanced past Clark to double Rangers’ lead.

That should have been that, and when Joe Garner came on for Miller just after the hour and somehow hit the post when it was easier to score from a couple of yards out there still looked only one winner.

Read more: Graeme Murty: Last-gasp Rangers heroics show players DO care about club

But then, the introduction of St Johnstone’s own sub put the cat among the pigeons.

Wotherspoon replaced Danny Swanson with 20 minutes left on the clock and within three minutes he had dragged his side back into the game. He picked the ball up on the left before driving towards the box and dummying Toral before curling an effort high past Foderingham into the opposite top corner.

Things went from bad to worse for Rangers minutes later as Kiernan went through the back of Graham Cummins needlessly on the touchline, with referee Kevin Clancy producing a straight red card.

If that decision had vexed the crowd, it was nothing compared to what was to come three minutes from the end as the visitors won a corner.

Craig swung a ball in that was only partially cleared, and there was Anderson on the penalty spot to side-foot the ball home as the Saints looked to have claimed a point.

Hyndman refused to accept such a fate however, and after clattering the bar he popped up on the edge of the area to coolly sidefoot home the winner two minutes into injury-time and send Ibrox wild.

RANGERS: Foderingham; Tavernier, Kiernan, Hill, Wallace; Holt, Hyndman, Toral (Halliday, 82’), Holt; Miller (Garner, 64’), Waghorn (Wilson, 78’).

Scorers: McKay (22’), Waghorn (49’), Hyndman (92’)

Booked: Hyndman (89’)

Sent off: Kiernan (78’)

ST JOHNSTONE: Clark; Watson (Coulson, 82’), Anderson, Shaughnessy, Easton; Foster, Craig, Paton, Alston (Cummins, 67’), Swanson (Wotherspoon, 70’); MacLean.

Booked: Craig (59’), Paton (69’)

Scorers: Wotherspoon (73’), Anderson (87’)