Barry Robson scored the winner for Dundee United from the penalty spot and was then red carded in stoppage time as rivals Dundee dropped a division.
After winning the penalty himself, Robson smashed the ball home causing wild celebrations. His second yellow card for dissent moments later took the shine off his day.
Inverness Caledonian Thistle player/boss Craig Brewster found himself in the strangest of scenarios. Here was the man who scored United's winning Tennent's Scottish Cup goal in 1994 with a chance to guide his new team to victory, possibly sending his old club tumbling into the murky depths of the first division.
As he did last week at Dens Park, Dundee, Brewster put himself on the bench, dictating proceedings off the field alongside assistant, Malky Thomson - for a while at least!
The positive factor for United was that their SPL destiny from the outset was in their own hands and a draw or win was always going to be enough to keep them up. Next weekend, of course, they are Hampden-bound to take on Celtic in the Scottish Cup Final.
There was a delay of more than ten minutes due to the late arrival of the visitors who were held up by roadworks on the A9.
The best chances early in the game included a Grant Brebner header and a Mark Kerr drive that was saved by keeper Mark Brown.
At the other end, a Liam Fox half-volley dipped just over the bar on 18 minutes. Brebner picked up a yellow card on 31 minutes after a very rash challenge on Black.
Brewster entered play moments later after Bayne suffered a hefty knock. Robson could have grabbed the advantage for the Taysiders before the break but a fine Brown save denied the ex-Inverness winger.
With Dundee and Livi level at the break, United were in pole position to survive. Very few chances were created in the second half, but Brewster came closest on 63 when he headed wide from a Black delivery.
United grabbed the winner with eight minutes to go when Robson hammered home a penalty after tumbling under a challenge from Ross Tokely. The celebrations behind the goal led to a pitch invasion from the United fans for a moment.
They went even more crazy moments later when they heard their rivals Dundee had been relegated by their draw at Livingston.