Dundee United's relegation from the Scottish Premiership was confirmed as Motherwell produced a comeback victory.
Kevin van Veen scored for a record 11th straight game to put the hosts in front, but Jamie McGrath scored from the spot and Steven Fletcher put United in front to keep their hopes of a scarcely believable escape just about alive.
However, Blair Spittal's excellent low drive drew Motherwell level, before Max Johnston's powerful header ensured Stuart Kettlewell's side ended the season with a win.
United finish bottom of the league, having conceded 70 league goals, while Motherwell end the season in the comfortable perch of seventh.
Motherwell started by far the better of the two sides, with Blair Spittal testing Jack Newman from distance, before Van Veen rounded the United keeper to continue his remarkable recent goal-scoring run, passing the mark of 10 games set by Marco Negri and Mark Viduka.
From that point though, Motherwell went into their shells and United grew into the contest. Liam Kelly denied Glenn Middleton twice, and Fletcher saw a shot cleared off the line.
Fletcher then volleyed wide after Bevis Mugabi failed to deal with a long ball over the top, but United disappointment soon turned to delight as VAR Willie Collum advised referee Steven McLean to go to the monitor, and a quick check showed the ball had struck Mugabi's arm as he challenged for the ball.
Jamie McGrath dispatched the penalty, and Jim Goodwin's side could have gone into the break in front, but Fletcher's header went wide off the base of the post.
Just three-and-a-half minutes into the second half, Fletcher had his goal. Peter Pawlett burst into the box after linking up with McGrath, and squared to the veteran striker who swept home with ease.
The goal seemed to spark Motherwell back into life. Mugabi forced a fine save from Newman from close range, and then Sean Goss' deflected shot came back out off the post.
Motherwell continued to pile bodies forward, and were deservedly level when Spittal found the bottom corner from the edge of the box, after a clever lay-off from Van Veen.
Johnston then lashed home a rebound after Van Veen's goal-bound shot was blocked, but the assistant's flag went up and cut short the home celebrations.
However, the pressure told. Johnston headed home James Furlong's cross, and gave the far-side assistant an appreciative hug when this time he kept his flag down.
In truth, Motherwell could have added to the scoreline in the closing stages, as they cut through United's porous defence again and again.
Player of the Match - Kevin van Veen
A goal and an assist for Motherwell's talisman. He was a constant threat, linking up wonderfully with his fellow forward players and finding pockets of space with his elusive movement.Dismal Dundee United end season with a whimper - analysis
Jim Goodwin's side arrived in Lanarkshire knowing that their hopes of survival were slim-to-none, and their defensive efforts on the day left them with no chance of overhauling Ross County in 11th.
They conceded three, and on another day, it could have been five or six - Motherwell got in behind with alarming ease against a unit whose confidence is understandably shot to pieces.
The period before and after half-time was impressive, showing fight and determination to get back into the contest, but they weren't able to maintain that level, and had no answer to Motherwell's attacking prowess.
For the hosts, they go into next season with real momentum. When Stuart Kettlewell arrived in February, Motherwell were the stand-out candidates for relegation, not scoring enough goals, and shipping plenty, but Kettlewell has done a wonderful job, rebuilding morale and lighting a fire underneath Van Veen.
This may well have been the Dutchman's farewell, and what a way to bow out in front of an adoring crowd. He finishes the season with 29 goals, and has been unplayable at times in the last few weeks.
What the managers said
Motherwell manager Stuart Kettlewell: "You could see how desperate we were to win the game. We didn't feel we hit our levels in the first 45 minutes. Maybe didn't have the same intensity that we've had on this run. Full marks to the players, they responded in the correct fashion in the second half.
"Kevin (Van Veen) speaks for himself with his goal return and his performance, but it's never about one person. There's a number of guys in there that have really put their shoulder to the wheel.
"Kevin's been brilliant, but he'll tell you that his teammates have helped him dramatically. Clubs are naturally making enquiries - he's scored 29 goals.
"My job is to take this on now, and make sure we're well set as a football club."
Dundee United manager Jim Goodwin: "I thought we played well in the first half, in terms of possession and getting into good areas. We were dominating the ball and then one attack from Motherwell and we're 1-0 down. That's been the story of the season, gifting the opposition the first goal.
"We can't defend the number of goals we've conceded. It's obscene and that's something we need to sort out. That's the first priority for me.
"We need to get the right types in the building, ones that can handle the expectation. Characters, leaders; those kind of signings are crucial. I want players who really want to be here, that's the bottom line. Finances don't really come into it. I need players who are 100% committed."
Line-ups
Motherwell
Formation 3-4-1-2
1Kelly
16McGinn5Mugabi20Blaney
2O'Donnell27Goss38Miller24Furlong
7Spittal
21Mandron9van Veen
1Kelly16McGinn5Mugabi20BlaneyBooked at 56mins2O'DonnellSubstituted forJohnstonat 65'minutes27Goss38MillerBooked at 52minsSubstituted forSlatteryat 65'minutes24Furlong7SpittalSubstituted forCorneliusat 90+2'minutes21MandronSubstituted forObikaat 65'minutes9van VeenSubstitutes
8Slattery13Oxborough15Aitchison17McKinstry18Cornelius22Johnston26Tierney49Ferrie99ObikaDundee Utd
Formation 4-2-3-1
31Newman
22Freeman27Ayina6Graham16Behich
14Sibbald19Levitt
15Middleton18McGrath8Pawlett
9Fletcher
31Newman22Freeman27Ayina6Graham16Behich14Sibbald19LevittSubstituted forFotheringhamat 66'minutes15MiddletonSubstituted forAnim Cudjoeat 65'minutes18McGrath8PawlettSubstituted forMacleodat 71'minutes9FletcherSubstituted forThomsonat 86'minutesSubstitutes
1Birighitti3McMann4Mulgrew7Niskanen23Harkes25Fotheringham28Anim Cudjoe39Thomson44MacleodReferee:Steven McLeanAttendance:5,971Live Text
Match ends, Motherwell 3, Dundee United 2.
Second Half ends, Motherwell 3, Dundee United 2.
Substitution, Motherwell. Dean Cornelius replaces Blair Spittal.
Mathew Anim Cudjoe (Dundee United) wins a free kick in the defensive half.
Foul by James Furlong (Motherwell).
Foul by Rory Macleod (Dundee United).
Bevis Mugabi (Motherwell) wins a free kick in the defensive half.
Substitution, Dundee United. Miller Thomson replaces Steven Fletcher.
Foul by Mathew Anim Cudjoe (Dundee United).
James Furlong (Motherwell) wins a free kick in the defensive half.
Attempt blocked. Jamie McGrath (Dundee United) right footed shot from outside the box is blocked.
Mathew Anim Cudjoe (Dundee United) wins a free kick in the attacking half.
Foul by James Furlong (Motherwell).
Steven Fletcher (Dundee United) wins a free kick in the attacking half.
Foul by Shane Blaney (Motherwell).
Goal! Motherwell 3, Dundee United 2. Max Johnston (Motherwell) header from the centre of the box to the high centre of the goal. Assisted by James Furlong with a cross.
Attempt missed. Callum Slattery (Motherwell) right footed shot from outside the box is too high from a direct free kick.
Foul by Kai Fotheringham (Dundee United).
Sean Goss (Motherwell) wins a free kick in the attacking half.
Corner, Motherwell. Conceded by Jack Newman.
Player of the match
GossSean Goss
Motherwell
Squad number27Player nameGoss
Squad number9Player namevan Veen
Squad number22Player nameJohnston
Squad number18Player nameCornelius
Squad number8Player nameSlattery
Squad number99Player nameObika
Squad number24Player nameFurlong
Squad number1Player nameKelly
Squad number7Player nameSpittal
Squad number16Player nameMcGinn
Squad number21Player nameMandron
Squad number5Player nameMugabi
Squad number2Player nameO'Donnell
Squad number20Player nameBlaney
Squad number38Player nameMiller
Dundee United
Squad number8Player namePawlett
Squad number16Player nameBehich
Squad number9Player nameFletcher
Squad number15Player nameMiddleton
Squad number44Player nameMacleod
Squad number18Player nameMcGrath
Squad number31Player nameNewman
Squad number39Player nameThomson
Squad number19Player nameLevitt
Squad number25Player nameFotheringham
Squad number14Player nameSibbald
Squad number27Player nameAyina
Squad number6Player nameGraham
Squad number22Player nameFreeman
Squad number28Player nameAnim Cudjoe