Match ends, St. Mirren 1, Hamilton Academical 2.
Hamilton Academical's fight for top-flight survival is "like climbing Everest with your flipflops on", said Brian Rice after they beat St Mirren.
After nine games with a win, bottom side Accies are now just two points behind 11th-placed Kilmarnock.
After goals from Ross Callachan and David Moyo, the visitors held on despite Jamie McGrath pulling one back.
"It would be the biggest achievement I've ever achieved with what we've been through this season," said Rice.
"I'm absolutely delighted to come and win. It's massive. I said yesterday we need to do what we need to do then look at the situation. It's going to go down to the last game.
"Everyone gave full effort. People throw their bodies on the line every week and that's what we need.
"It's not belief into the squad I need, it's getting my quality players on the pitch - that's been the problem. My flair players have all been injured, but I can't ask for any more than what I got."
The win sets up a grandstand finish to the season, with the Lanarkshire men's two remaining games of the season against the only sides they can catch - away to Ross County, followed by Kilmarnock at home.
These two had history of breaking each others' hearts this season. An 89th-minute Hamilton goal had denied St Mirren a place in the top six, then Jim Goodwin's side gained revenge with a thumping 3-0 Scottish Cup win.
But a win for St Mirren this time could do more than just hurt Accies, with their Premiership survival on the line.
Kristian Dennis almost got a toe to an early St Mirren cross, while Callachan burst on to a back pass but poked wide at the other end. It was the best of a flurry of half chances from both sides.
The visitors grew as a force the longer the half went on, and deservedly took the lead after a bit of head tennis in their box created an opening for Callachan, who knocked the ball in from close range.
Bruce Anderson appealed for a penalty after a shove from Conor McCarthy, but went down too easily to impress referee John Beaton.
However, the on-loan Aberdeen striker was to be pivotal as Accies doubled their lead. He cracked a low shot at goal that hit Moyo and trickled over the line.
Kyle McAllister went close to pulling one back for St Mirren when he latched onto a loose header, but goalkeeper Kyle Gourlay showed quick reactions to palm it away.
Moments later Callachan crashed a shot off the crossbar as Accies threatened a third, then Anderson turned in the box and forced Jak Alnwick into a fine low save.
But McGrath, moments after coming off the bench, hit a sweet low strike past Gourlay to pull one back for St Mirren and suddenly the game was alive again.
And Jay Henderson should have levelled when he found space on the right, but sent his shot wide with the goal at his mercy and Hamilton held on for the three points.
Man of the match - Bruce Anderson
What did we learn?
St Mirren had one eye on next weekend's Scottish Cup semi-final with St Johnstone. That was evident by the four changes Goodwin made, though that only ended up being three after Marcus Fraser was injured in the warm up.
But after going 2-0 down, the Paisley side showed the quality that has taken them to Hampden and they will be kicking themselves they didn't pull back the two-goal deficit.
Accies' desperation was evident, and although both goals they did score were untidy, they also had other big chances. And the confidence will be flowing ahead of two huge final games of the season.
What did they say?
St Mirren manager Jim Goodwin: "It was a really disappointing performance. I thought we were very flat. We made a few changes but I didn't believe they would have the negative impact they did have.
"We gave a few an opportunity and I don't think a few boys took that opportunity. We could have nicked a point at the end but I don't think we would have deserved that."
Hamilton head coach Brian Rice: "It got a wee bit nervous towards the end but I think we deserved to win. We played really well, we had chances and scored two goals. I thought the boys were fantastic.
"We spoke about starting fast and getting on the front foot and we did that. To come here and get three points is massive for us.
St Mirren take on St Johnstone in the Scottish Cup semi-finals on Sunday 9 May (14:15 BST), before a trip to Kilmarnock in the Premiership the following Wednesday (19:45).
Hamilton must wait until Wednesday 12 May for their next game, when they travel to Ross County (19:45).
- 7Doyle-HayesBooked at 90mins
- 25ErhahonBooked at 32mins
- 2TaitSubstituted forDurmusat 62'minutes
- 14MacPhersonSubstituted forMcGrathat 61'minutes
- 20DennisSubstituted forMcAllisterat 72'minutes
- 45QuanerSubstituted forErwinat 61'minutes
- 34CallachanBooked at 13minsSubstituted forThomasat 90+1'minutes
- 18MimnaughSubstituted forStangerat 89'minutes
- 21MunroSubstituted forSmithat 87'minutes
- 7AndersonSubstituted forSmithat 88'minutes
- John Beaton
- Shots on Target
Second Half ends, St. Mirren 1, Hamilton Academical 2.
Foul by Joe Shaughnessy (St. Mirren).
Nathan Thomas (Hamilton Academical) wins a free kick in the defensive half.
Lee Erwin (St. Mirren) wins a free kick on the left wing.
Foul by Hakeem Odoffin (Hamilton Academical).
Substitution, Hamilton Academical. Nathan Thomas replaces Ross Callachan.
Jake Doyle-Hayes (St. Mirren) is shown the yellow card for a bad foul.
Foul by Jake Doyle-Hayes (St. Mirren).
Ross Callachan (Hamilton Academical) wins a free kick on the left wing.
Substitution, Hamilton Academical. George Stanger replaces Reegan Mimnaugh.
Substitution, Hamilton Academical. Callum Smith replaces Bruce Anderson.
Substitution, Hamilton Academical. Lewis Smith replaces Kyle Munro.
Foul by Daniel Finlayson (St. Mirren).
David Moyo (Hamilton Academical) wins a free kick in the attacking half.
Attempt missed. Jay Henderson (St. Mirren) right footed shot from the centre of the box is just a bit too high. Assisted by Lee Erwin.
Attempt missed. Ilkay Durmus (St. Mirren) left footed shot from the left side of the box is too high following a corner.
Corner, St. Mirren. Conceded by Jamie Hamilton.
Attempt blocked. Lee Erwin (St. Mirren) left footed shot from the left side of the box is blocked. Assisted by Jamie McGrath.
Corner, St. Mirren. Conceded by Aaron Martin.