Billy Mehmet congratulates Saints scorer Stephen McGinn
A tremendous curling left-foot strike by Stephen McGinn on 77 minutes gave St Mirren a stunning win over Rangers.
The Ibrox side had the bulk of possession but the Buddies defended stoutly as they welcomed Rangers to Love Street for the last time.
As the final whistle approached, Gers sub Kris Boyd's header hit the post and Kirk Broadfoot and Kyle Lafferty both had headers cleared off the line.
But St Mirren held on for their first home league win over Gers since 1986.
Rangers now trail SPL leaders Celtic on goal difference after a largely lethargic display, while the victory lifts St Mirren off the bottom and up to 10th spot in the table.
The Buddies, who will move to a new stadium in January, survived several late scrambles in their penalty area but McGinn's wonderful goal was worthy of winning any match.
St Mirren made a useful start and had Rangers pinned inside their own half, with full-back Jack Ross galloping forward at every opportunity.
For all the early promise, a pattern soon emerged where the hosts contained the visitors by getting numbers behind the ball and Rangers struggled to get behind the Saints defence.
Much to the chagrin of Boyd, Rangers boss Walter Smith left his joint-top scorer on the bench once more, opting for pace in attack.
And a counter-attack after 18 minutes suggested Smith's decision would ask questions of the Saints' defence.
Steven Davis released Jean-Claude Darcheville down the right wing and his explosive speed created the space for a fine cross for Miller but the in-form striker was denied by Scott Cuthbert's timely intervention.
Kevin Thomson was the first to test either of the goalkeepers. The Rangers midfielder pounced on a slack pass by Gary Mason, swept forward and let fly from 25 yards.
Mark Howard's positioning was exemplary, though, and he was able to parry.
Thomson threatened Howard's goal again on 39 minutes. First combining with Mendes, he burst forward, worked a one-two with Miller and clattered a shot which the keeper tipped over.
Rangers defender Madjid Bougherra wasted a chance from Charlie Adam's inswinging corner at the beginning of the second half. Unmarked on the six-yard line, he mistimed his jump and headed over.
Darcheville was next to have a go, streaking forward from left to centre and shooting ferociously straight at Howard.
The Frenchman's last contribution before the introduction of Boyd was a dash down the right and a cross into the danger area, which Miller poked narrowly wide under pressure from Cuthbert.
Immediately Boyd began to win headers up front, and with 15 minutes to go he bulleted a header at goal, but it was too far out to trouble Howard.
St Mirren took the lead through substitute McGinn, who had only been on the park for five minutes.
Jean-Claude Darcheville is challenged by Saints' Will Haining
Craig Dargo made an intelligent run to pull the retreating Rangers defence out of position and McGinn curled a beautiful shot past the re-instated Allan McGregor from 20 yards.
Rangers piled on the pressure, with Boyd hitting the post, Kyle Lafferty being denied by a goal-line clearance and a cluster of defenders keeping out Broadfoot's looping nod, but St Mirren held their nerve to register a famous win.
St Mirren manager Gus MacPherson: "That's a vital three points for us. I think we earned our luck in last 15 minutes because we put so much into the game.
"We pressed and pressured good players and eventually that takes its toll.
"In the last period the players were throwing their bodies on the line
"I was delighted with our shape and discipline. The only problems came when we tried to be too cute and gave the ball away in dangerous areas."
Rangers manager Walter Smith: "St Mirren always well organised and worked very hard. We had a lot of the ball in the first hour but didn't create any clear-cut chances.
"Maybe if we'd started a bit brighter there might have been a different reflection on the game.
"Throughout the match, we struggled in that respect and it was only in the latter stages when we applied a lot of forceful pressure that we looked as though we were going to get a goal or two."
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.