Hearts secured the final UEFA Champions League place in Scotland with a 1-0 victory over Aberdeen.
Needing a win to secure second and avoid a one-match showdown with Rangers on the last day of the season, The Jambos were frustrated in the early stages by an Aberdeen side unbeaten in seven and chasing a Uefa Cup place of their own.
While The Dons offered little going forward they were resilient in defence, and Hearts had to wait until 19 minutes before half time before carving out their first meaningful opportunity, Rudolf Skacel shooting narrowly wide from Roman Bednar's cross.
Roared on by a passionate Tynecastle crowd Hearts made the crucial breakthrough after 54 minutes, Paul Hartley converting a penalty following Alexander Diamond's desperate handball.
Incredibly Diamond was not sent off for blatantly punching away Bednar's goalbound effort, but Aberdeen's will was broken and they never looked like levelling.
Substitute Saulius Mikoliunas missed a fantastic chance to add to Hearts' account, while Aberdeen's Scott Severin was red carded for a lunge at Bruno Aguiar on the touchline.
The final whistle sparked jubilant scenes on the terraces, and would also have been welcomed by Gretna supporters, as Hearts' success handed the minnows a place in Europe by virtue of their Scottish Cup run.
In the day's other games, champions Celtic bounced back from their crushing 3-0 defeat at Hearts last weekend by comfortably seeing off Kilmarnock 2-0.
After a tight first half, Maciej Zurawski (55) and Stanislav Varga (63) sealed the win for Gordon Strachan's side.
Falkirk's struggles continued with a 2-0 loss at Inverness Caledonian Thistle, Russell Duncan (18) and Craig Dargo (30) finding the back of the net for the home team.
Livingston are already relegated but would have been looking for a win in their final home game of the season. However, a David Clarkson strike (74) ensured that Motherwell left The City Stadium with all three points.
Click below for match summaries:
Celtic 2-0 Kilmarnock
Hearts 1-0 Aberdeen
Inverness CT 2-0 Falkirk
Livingston 0-1 Motherwell