Ross County have been relegated for the second season running after losing at Raith Rovers on the Scottish Championship's final day.
County needed to win in order to climb off bottom spot and led through Kieran Phillips' header from a free-kick on 16 minutes.
That advantage lasted an hour, with Innes Cameron nodding the hosts level. Raith Rovers moved ahead for the first when Jack Hamilton headed them in front with 10 minutes to go.
Jayden Carbon finished well from close range to bring the visitors level in added time but there were further twists as Declan Gallagher felled Cameron in the box and Josh Mullin converted the penalty seconds before full-time.
And there were ugly scenes after the whistle as a confrontation of both sets of players ensued in the County penalty area, with County's Akil Wright dismissed.
Ross County manager Stuart Kettlewell commented afterwards: "We start fighting and we start showing loads of emotion at the end of the game. We've had 36 games to do that and we've not done that enough throughout the course of the season.
"So, I don't know, sometimes that wee bit that comes from Raith Rovers, that bit that comes from ourselves, I think from both sides it's classless because I think you've got an opportunity to do something before it ever gets to that."