A last-gasp winner from substitute Rory Boulding against Aberdeen secured the coveted final top-six spot for Dundee United - with a little help from their city rivals.
Defeat for Kilmarnock at the hands of Dundee, combined with the late strike at Tannadice, ensured United a place in the top half of the Scottish Premier League table beyond the split.
Killie had been in the driving seat to claim the top six berth, with United, the Dons and Hibernian also in contention at the start of the day.
The eventual outcome meant a disappointing end to Aberdeen boss Craig Brown's 36-year managerial career as he now steps aside for Derek McInnes to take over the reins at Pittodrie.
United were boosted by the return of John Rankin from suspension, with Stuart Armstrong banned and Gary Mackay-Steven named on the bench after injury.
The Dons added fit-again Gary Naysmith to their side for the clash at Tannadice.
Mark Millar tried his luck with a shot from distance that fell wide of the target as the home side pushed for an early opener.
Aberdeen then had a chance of their own when Millar conceded a foul and Niall McGinn's resultant free-kick from just outside the box fizzed past the upright.
Chances in front of goal were limited for both sides in an evenly-matched affair in the first half.
But the visitors were threatening again through another set-piece, when Jonny Hayes punted a free-kick into the box and Russell Anderson glanced a header wide.
At the other end, a mix-up between the Dons defender and goalkeeper Jamie Langfield almost gifted United the opener but Ryan Gauld failed to find the target.
Jon Daly then squandered a great chance to grab the opener just before the interval, ballooning over when he should at least have tested Langfield.
The Dons were out of the traps quickly after the break and Radoslaw Cierzniak was called into action to beat away McGinn's header a minute after the restart.
United had a chance to pile on the pressure with a free-kick but Barry Douglas rifled into the wall, before Rankin blasted the rebound wide.
The home side then threw Mackay-Steven into the action after 53 minutes and the winger immediately lit up the match.
He burst through on goal and looked certain to find the back of the net but delayed pulling the trigger and allowed Mark Reynolds to make a superb block before he could unleash the shot.
The woodwork then prevented United from opening the scoring when Langfield blocked a Gauld shot and Willo Flood's follow-up header smacked off the crossbar, before Mackay-Steven eventually nodded over.
United pushed forward in numbers and the Aberdeen goalkeeper did well to claw a net-bound Daly header away from the gaping net.
Langfield came to the rescue again moments later with a brilliant double save, firstly blocking Gauld's header, before preventing Daly's shot from finding the target.
McGinn then drew a decent save from the United keeper with two minutes to go, before substitute Rory Fallon's long-ranger was touched just wide.
The match ended in dramatic scenes when Boulding kept his composure to rifle past Langfield deep into injury time to secure the last top-six spot.