Kal Naismith's goal edged an under-par Rangers through to the third round of the Scottish Cup at 10-man Forres Mechanics' expense.
The Highland League champions received a standing ovation at full-time for pushing their illustrious opponents all the way.
Referee Crawford Allan waved away home penalty appeals when Sebastien Faure appeared to fell Scott Moore.
And Naismith's goal proved enough to send Ally McCoist's side through.
Rangers broke the deadlock in the 13th minute, when Naismith calmly fired past goalkeeper Stuart Knight.
Forres almost equalised in the 28th minute, with Moore just inches away from connecting with a cross and Rangers goalkeeper Neil Alexander saved a Nathan Sharp header moments before the break.
Rangers dominated the early stages of the second half and, although they failed to create any real openings, it appeared Forres were running out of steam.
But, in the 60th minute, a free-kick resulted in a scramble in the Rangers box and a close-range strike from Forres forward Kyle Scott forced a good stop from Alexander.
Then disaster for Mechanics: with 25 minutes remaining, Sharp was sent off for a second yellow card for handball and it looked like being game over.
However, Rangers continued to struggle to create any real goal scoring opportunities.
A volley from substitute Robbie Crawford, brilliantly tipped over by Knight, was about as good as it got.
Forres threatened from set-pieces, defender Graham Fraser's header flying just wide, but Rangers held on to progress to the next round.
Rangers continue to make heavy weather of it away from home against supposedly inferior opposition.
Yes, these teams raise their games because it's Rangers they're playing (Forres trained three days this week rather than the normal two), but a club with the resources of Rangers should not be struggling as much as they are in these games.
Creating chances is a real problem. Fraser Aird made the goal for Naismith, but apart from that, opportunities were rare, with the hustle and bustle of Lee McCulloch in an advanced role providing most of the impetus.
As usual, a sizeable contingent of the Rangers faithful were in attendance. However, unless performances improve, you wonder if the novelty of visiting these footballing outposts might soon begin to wane.