Match ends, Livingston 2, Dundee 1.
Livingston secured a seventh-place Scottish Premiership finish with a comeback victory as Dundee ended their one-year stay in the top flight with another disappointing defeat.
Mark McGhee, whose visitors were officially relegated in midweek, finishes his 14-game spell in charge with one win and eight losses.
Josh Mulligan's second-half header looked like it was going to earn Dundee a second straight win, but goals from Andrew Shinnie and Alan Forrest turned the game around.
It means Livingston end the season unbeaten in five games - and in four meetings with Dundee, winning three in a row.
Wednesday's 3-1 win over Hibernian - Dundee's first under McGhee - had come too late to save the manager's job, or the team from relegation, but it was little surprise that he stayed loyal to that winning XI.
David Martindale took the opposite approach, only retaining two of the side that drew with St Mirren in midweek, and the home side looked like a team still finding their feet in the early stages.
Paul McMullan flashed a drive just wide and, from the corner, midfielder Max Anderson's flick on the spin crashed off a post, while Niall McGinn and Ryan Sweeney also both threatened.
Craig Sibbald did fire against the outside of a post at the other end and Dundee survived calls for a red card when Jordan Marshall challenged Cristian Montano when through on goal. The Livingston winger was instead shown a yellow for simulation by referee John Beaton.
Max Stryjek, who Martindale restored to the starting line-up despite expecting the Pole to be sold this summer, was the first goalkeeper to be tested as he superbly pushed a looping McMullan effort over the crossbar.
It was Harrison Sharp's turn to keep the score level when turning an Adam Lewis shot over the crossbar after the on-loan Liverpool full-back's fine one-two with Montano.
Montano volleyed just wide after the break, but it was Dundee who made the breakthrough when Mulligan headed in a Jordan Marshall cross to the back post for the midfielder's third goal of the season.
There was a sentimental moment as goalkeeper Gary Maley was handed his Premiership debut at the age of 39 and the applause was still ringing round the Tony Macaroni when Shinnie knocked in a low Forrest drive from close range.
The winger, who is expected to leave this summer, completed the turnaround moments later with a curling drive and Maley had time to produce his one and only save - and a good one it was as he turned McGinn's effort over the crossbar.
Man of the match - Alan Forrest
What did we learn?
Winning despite making so many changes shows the depth of the squad Martindale has assembled as Livingston again finished above clubs with higher budgets.
However, the contribution of clever winger Forrest and steady goalkeeper Styjek shows that the manager will again have to show his eye for a bargain in the transfer market to replace two such important players should they leave as expected.
McGhee told BBC Scotland before kick-off that he was "100% behind" Dundee's decision that, in the second tier, they will need a young coach who can contribute more energy on the training ground than a pure team manager.
Veteran midfielder Charlie Adam was unable to lead Dundee to victory as a substitute on this occasion, but his words this week suggest he is angling for a shift into management and will surely be in contention if he throws his hat into the ring.
What they said
Livingston manager David Martindale: "I think that's Alan's last game for Livingston. When players leave, it can be a sore one, but if he is leaving to one of the top four clubs in Scotland, you've just got to wish him well. I know Hearts have an interest along with other clubs. It would be a fantastic move for him if it happens.
"I just hope Sportscene shows big Stretch's save. I played with him at Broxburn, I brought him in seven-and-a-half years ago when I needed a goalkeeper and I've been trying to retire him for four years, but things conspired against us. He is a legend for us and I'm delighted he got on at the end."
Dundee assistant Dave Mackay: "That's another manager gone and it's a disappointing way to end the season. We just have to start our rebuild.
"We are leading but lose two goals in the last 15 minutes and that just about sums up our season."
- 32StryjekSubstituted forMaleyat 75'minutes
- 21McMillanSubstituted forDevlinat 60'minutes
- 15BoyesSubstituted forat 83'minutes
- 10SibbaldSubstituted forPittmanat 69'minutes
- 11MontañoBooked at 23minsSubstituted forForrestat 60'minutes
- 12SotoSubstituted forNoubleat 60'minutes
- 3MarshallBooked at 67minsSubstituted forDaley-Campbellat 76'minutes
- 18McMullanSubstituted forMcCowanat 45'minutes
- 15MulliganBooked at 20mins
- 24AndersonSubstituted forAdamat 76'minutes
- 20RuddenSubstituted forMullenat 64'minutes
- John Beaton
- Shots on Target
Second Half ends, Livingston 2, Dundee 1.
Corner, Livingston. Conceded by Cammy Kerr.
Attempt missed. Cammy Kerr (Dundee) header from the centre of the box is close, but misses to the right. Assisted by Luke McCowan with a cross following a corner.
Corner, Dundee. Conceded by Adam Lewis.
Offside, Livingston. Joel Nouble tries a through ball, but Alan Forrest is caught offside.
Attempt missed. Daniel Mullen (Dundee) header from a difficult angle on the left is close, but misses the top left corner. Assisted by Charlie Adam with a cross following a corner.
Corner, Dundee. Conceded by Gary Maley.
Attempt saved. Niall McGinn (Dundee) right footed shot from the centre of the box is saved in the top centre of the goal. Assisted by Daniel Mullen.
Attempt missed. Luke McCowan (Dundee) left footed shot from the left side of the box misses to the left. Assisted by Charlie Adam.
Attempt blocked. Daniel Mullen (Dundee) right footed shot from outside the box is blocked. Assisted by Luke McCowan.
Attempt missed. Ryan Sweeney (Dundee) header from very close range is too high. Assisted by Charlie Adam with a cross following a set piece situation.
Foul by Stephane Omeonga (Livingston).
Cammy Kerr (Dundee) wins a free kick on the left wing.
Attempt blocked. Josh Mulligan (Dundee) right footed shot from the centre of the box is blocked. Assisted by Vontae Daley-Campbell.
Goal! Livingston 2, Dundee 1. Alan Forrest (Livingston) left footed shot from the right side of the box to the bottom left corner. Assisted by Odin Bailey.
Morgan Boyes went off injured after Livingston had used all subs.
Morgan Boyes (Livingston) wins a free kick in the defensive half.
Foul by Niall McGinn (Dundee).
Offside, Livingston. Odin Bailey tries a through ball, but Alan Forrest is caught offside.