Hibernian, Queen of the South or Rangers will face Motherwell in the relegation play-off after the Lanarkshire side lost to St Mirren.
Motherwell were condemned to a relegation play-off after suffering a 2-1 defeat to bottom club St Mirren in the Scottish Premiership, while Kilmarnock's 4-1 thrashing of Partick Thistle was overshadowed by an on-field skirmish between two team-mates.
St Mirren, whose fate was already sealed, went behind at Firhill as John Sutton converted from the penalty spot when Lee Erwin was fouled by Thomas Reilly.
Jason Naismith bundled home an equaliser for St Mirren and Motherwell were reduced to 10 men - Scott McDonald receiving his marching orders - before Stephen Mallan grabbed a last-minute winner.
Motherwell will now face Hibernian, Queen of the South or Rangers in a two-legged tie to decide who will secure a spot on next season's top flight.
The Lanarkshire side cannot finish above the bottom two after fellow strugglers Kilmarnock and Ross County - who face one another on the final weekend - beat Patrick Thistle and Hamilton Academical respectively.
Tope Obadeyi was Kilmarnock's hero, scoring either side of half-time in a 4-1 away win after Jamie Hamill opened the scoring.
Hamill was later involved in a fracas with Josh Magennis, who appeared to headbutt his team-mate and could yet find himself in trouble.
Conrad Balatoni headed in for Patrick to reduce the arrears before Magennis made an impact for the right reasons by completing the scoring.
Ross County were forced to come from behind as Lucas Tagliapietra converted Ali Crawford's corner to give Hamilton a half-time lead at the Global Energy Stadium.
Michael Gardyne levelled, but County had Filip Kiss sent off by the time Liam Boyce sealed a pivotal 2-1 win.
Dundee could not end a run of five straight defeats with victory as Adam Rooney salvaged a last-gasp 1-1 draw for Aberdeen, while Europe-bound Inverness Caledonian Thistle were 3-0 winners over Dundee United.