Match ends, Dundee United 3, St. Mirren 2.
Dundee United won to send St Mirren into the Scottish Championship's relegation play-off spot.
Thomas Mikkelsen fired United ahead as St Mirren players claimed for a foul but Gary Mackenzie headed the Buddies level before the break.
Tony Andreu struck a free-kick from inside the box for the Tangerines' second only for Josh Todd to equalise.
But Blair Spittal's late shot gave the hosts the victory they craved, leaving St Mirren two points off bottom.
Ray McKinnon's United, who remain third and are assured of a promotion play-off place, took the lead in controversial circumstances. Striker Mikkelsen went in with a high boot on Mackenzie but referee Craig Charleston waved play on and the Finn hammered the ball high into the roof of the visitors' goal.
Mackenzie had to receive treatment at the side of the pitch with the entire St Mirren bench, including manager Jack Ross, furious by the call from the officials.
Buddies captain Stephen McGinn had a half-chance for an equaliser with a header from a Lewis Morgan cross but there was little pace on the ball, which was gathered by Cammy Bell in the home goal.
Stevie Mallan was again showing the type of skills that has brought about interest from English clubs and was inches away with a free-kick that ended up in the Dundee United goal's side netting.
St Mirren continued to drive forward and deservedly equalised before the break. Mallan whipped in a free-kick at pace from the right-hand side that was met by the head of Mackenzie and Bell was beaten.
Simon Murray crashed a shot off the St Mirren crossbar from 25 yards and United then regained the lead in bizarre circumstances. Keeper Billy O'Brien picked up a pass-back inside his own box under pressure from Murray.
The free-kick was slipped to Andreu, who drilled through a ruck of defenders.
The visitors pushed more and more men forward looking for the equaliser and they were rewarded for their persistent pressure when substitute Todd hooked home from 12 yards out.
However, the home side took the lead for the third time in the final minute when Spittal hammered home from 20 yards.
It was a cruel end to the game for St Mirren, who have two games left to get out of relegation trouble.
- 24RobsonBooked at 38mins
- 7SpittalBooked at 25minsSubstituted forDonaldsonat 90+2'minutes
- 35AllardiceSubstituted forKuateat 46'minutesBooked at 69mins
- 9MurrayBooked at 73mins
- 3IrvineSubstituted forDemetriouat 77'minutesBooked at 90mins
- 6MackenzieBooked at 8mins
- 11SmithSubstituted forSuttonat 69'minutes
- 16LoySubstituted forToddat 79'minutes
- Craig Charleston
- Shots on Target
Second Half ends, Dundee United 3, St. Mirren 2.
Hand ball by Kyle Magennis (St. Mirren).
Substitution, Dundee United. Coll Donaldson replaces Blair Spittal.
Stelios Demetriou (St. Mirren) is shown the yellow card for a bad foul.
Blair Spittal (Dundee United) wins a free kick on the right wing.
Foul by Stelios Demetriou (St. Mirren).
Goal! Dundee United 3, St. Mirren 2. Blair Spittal (Dundee United) right footed shot from outside the box to the bottom left corner.
Attempt missed. Thomas Mikkelsen (Dundee United) right footed shot from the centre of the box is close, but misses the top left corner.
Attempt blocked. William Edjenguele (Dundee United) right footed shot from outside the box is blocked.
Goal! Dundee United 2, St. Mirren 2. Josh Todd (St. Mirren) left footed shot from the left side of the box to the top right corner.
Corner, Dundee United. Conceded by Stelios Demetriou.
Jack Baird (St. Mirren) wins a free kick in the attacking half.
Foul by Thomas Mikkelsen (Dundee United).
Lewis Morgan (St. Mirren) wins a free kick in the defensive half.
Foul by Stewart Murdoch (Dundee United).
Substitution, St. Mirren. Josh Todd replaces Rory Loy.
Attempt saved. Jack Baird (St. Mirren) header from the centre of the box is saved in the centre of the goal.
Substitution, St. Mirren. Stelios Demetriou replaces Gary Irvine.
Corner, St. Mirren. Conceded by Jamie Robson.