A stunning last-minute strike from substitute Nicky Clark took Rangers into the quarter-finals of the Scottish Cup at Kilmarnock’s expense.
Martyn Waghorn’s early penalty was cancelled out by a fine Rory McKenzie strike in the pouring rain.
Rangers dominance finally paid off just as the game was heading to extra time when Clark fired in at the near post.
Victory over the Premiership side gives the Championship leaders a home tie against Dundee or Dumbarton.
Given their impressive 2-0 league win over Motherwell and the appointment of new manager Lee Clark, the home side had good reason to go into the game with confidence.
The 13,179 who braved the weather huddled under the Rugby Park stands as the incessant wind and rain lashed the players, but the Rangers supporters were on their feet after only two minutes.
Stuart Findlay brought down the advancing Waghorn just inside the box and referee Bobby Madden immediately pointed to the spot.
The Englishman looked to be struggling after the challenge, but he stepped up to send Jamie MacDonald the wrong way before his game was over and Clark replaced him.
The question was how would the home side respond.
The answer came four minutes later, when McKenzie found some space just inside the Rangers box and fired the ball low past goalkeeper Wes Foderingham to level.
A stunning strike and a stunning start to this cup tie despite the rain’s best efforts to dampen the occasion.
With tails well and truly up, Kilmarnock went looking for another and they probably should have taken the lead through Josh Magennis.
The Irishman caught Dominic Ball in possession and raced through on goal, but just as he prepared to shoot, Rob Kiernan slid in with a timely intervention to clear the danger.
After that, the game settled down and both sides traded blow after blow as the match swung from end to end.
Craig Slater forced a good save from Foderingham from distance and, at the other end, Kenny Miller pulled his shot just wide from eight yards.
The visitors started the second half with tremendous energy and intent, with Barrie McKay and James Tavernier both coming close.
McKay’s fizzing volley flew just wide and Tavernier’s long-range effort forced a good save from MacDonald.
As Rangers piled forward in numbers, they were leaving gaps at the back and Tope Obadeyi was finding space on the left, but despite some good runs, the Kilmarnock attacks were coming to nothing.
Rangers claims for a penalty on the hour also came to nothing. Lee Ashcroft looked to hold Kenny Miller back inside the box, but referee Bobby Madden was not interested despite the howls from the Rangers fans behind the goal.
What followed was a period of intense Rangers pressure as the Kilmarnock defence continued to bounce off the ropes.
Just as it looked like they would hold on for extra time, the killer blow came courtesy of Clark.
He bulleted the ball in at the near post after an inch-perfect corner from McKay to send Kilmarnock out of the cup.