Liam Craig was the man on the spot as St Johnstone claimed a deserved 1-1 draw against Rangers after a double dose of penalty controversy in Perth.
Steven Gerrard’s team thought they had warmed up for Sunday’s Scottish Cup showdown by edging to a narrow win in their McDiarmid Park dress rehearsal following Scott Wright’s first goal for the club.
But referee Euan Anderson – who had earlier performed a bizarre U-turn after overturning a Saints spot-kick award – did then hand the hosts a soft penalty in the third minute of stoppage time which Craig rammed home to seal a point.
It meant Callum Davidson’s team cut the gap on Livingston and a potential European slot to three points with three games remaining.
Rangers will be frustrated at the slip-up but at least their quest for an unbeaten league campaign lived on.
They will now turn their attention to doubling up on their league triumph when Saints travel to Glasgow for this weekend’s last-eight duel.
Gerrard clearly had an eye on Sunday’s quarter-final as he made seven changes to the team that dumped Celtic out of the last 16.
Skipper James Tavernier was back in a starting line-up for the first time since February after recovering from a knee injury while January signing Jack Simpson came in for his first start.
Saints rang the changes too as Zander Clark, Callum Booth, Ali McCann and Shaun Rooney returned for the Betfred Cup winners.
It was the newly crowned Premiership champions who started the shakier though as they survived an early onslaught.
Saints had tried a near-post corner routine three times without success during Saturday’s cup win over Clyde.
That did not stop them dusting it off again inside the first three minutes as Stevie May flicked back David Wotherspoon’s ball to the edge of the six-yard box but Craig shot straight at Jon McLaughlin.
Guy Melamed did have the ball in the net seconds later as he sneaked in behind Rangers’ backline but the offside flag was up by the time he fired home.
The Israeli was soon forced off with a migraine but only after nodding another Wotherspoon out-swinger straight at the keeper while totally unmarked.
Rangers looked a shambles at the back, with Simpson forced to scramble back and cut out a May ball for Melamed as Connor Goldson screamed in vain for offside with just seven minutes played.
They were not much better going forward, with a wasted free Simpson header and a Wright chance following a sublime Kemar Roofe ball over the top the only notable openings they created in the entire opening half.
But they got their act together at the interval and grabbed the opener within 10 minutes of the restart.
Steven Davis got the benefit of the doubt as the ball appeared to brush his arm. The Northern Irishman slotted in Wright, who cut inside and swept a fine right-foot finish past Clark to open his Rangers account.
Saints were unhappy with the decision to play on and were even angrier three minutes later when Anderson pointed to the spot as Borna Barisic and Rooney clashed in the box – only to then change his mind.
The home captain was standing over the spot ready to shoot but was then left stunned as Anderson decided to award a goal-kick instead after consulting with Frank Connor.
Rangers thought they had seen out the danger as the clock ticked past 90 minutes.
But when Roofe tried another needlessly spectacular effort from the half-way line, it handed St Johnstone one last chance and they got their rewards when Simpson barged over Christopher Kane, with Craig making no mistake from 12 yards.
What the managers said…
Rangers boss Steven Gerrard: “Look, as a team we are 1-0 up and you have got to make better decisions, decisions for the team rather than yourself. But he has tried that before and scored from the halfway line so who am I to tell him?
“But as a group, we have been really good this season with our game management and parking our ego up in the final moments of the game.
“Unfortunately tonight we paid for it. It was a penalty, we should have won the header and it was a combination of small errors. But I think over the course of the 90 minutes St Johnstone deserved that little bit of luck.”
St Johnstone boss Callum Davidson said: “I’m delighted, we started the game unbelievably well and caught Rangers cold a little bit.
“The only disappointing thing was we didn’t score a goal or two. Some of the chances were very good.
“Once we lost the goal we didn’t give up, we kept going and got our rewards in the end.
“It’s not often you play against Rangers and have more shots on target than they do, so that shows how well we played.
“We deserved at least a point and I’m really proud of the players.”
St Johnstone travel to Glasgow on Sunday to face Rangers again but this time in a Scottish Cup quarter-final showdown; kick-off 6.30pm.