Fabio Pisacane was the unlikely hero as Cagliari waved farewell to the Stadio Sant'Elia with a last-gasp 2-1 win over AC Milan in Serie A.
The defender pounced after Gianluigi Donnarumma had palmed Joao Pedro's stoppage-time free-kick into his path, as Milan paid the price for wasteful finishing and Gabriel Paletta's fifth dismissal of the season.
In the final competitive match at Cagliari's home ground, Vincenzo Montella's side – who were already assured of sixth spot and a Europa League berth – fell behind to Joao Pedro's 17th-minute goal.
It capped a bright start for the hosts, who responded well to their 6-2 thrashing at the hands of Sassuolo last time out, but Milan were dominant for the most part after the break.
The visitors – who were saying a goodbye of their own to captain Keisuke Honda on his last outing for the club – looked rejuvenated in the second half, but even the award of a questionable penalty was not enough to get them off the mark, with Carlos Bacca seeing his effort saved by Milan loanee Luca Crosta on his debut.
Gianluca Lapadula showed his team-mate how it was done with a second spot-kick, though, before Paletta's second yellow card handed the initiative back to Massimo Rastelli's men, who saw Han Kwang-song's strike ruled out for offside before Pisacane's first goal of the campaign sealed a dramatic triumph in the glorious Sardinian sunshine.
The hosts burst out of the blocks and saw two chances go to waste inside the first six minutes, with Marco Borriello heading wide and Artur Ionita rattling the crossbar at the end of a rapid counter-attack.
But Cagliari got the breakthrough they deserved when Joao Pedro collected Borriello's superb throughball and sent a cool finish beyond Donnarumma.
It provided a much-needed wake-up call for Montella's men, who came agonisingly close to levelling just four minutes later.
Bacca, who scored the winner in the reverse fixture, stretched to reach Paletta's flick-on from a corner, but his shot was pushed onto the underside off the crossbar by the alert Crosta.
Still Milan looked vulnerable at the back and Juraj Kucka had Donnarumma to thank for thwarting Diego Farias following a poor backpass.
Milan suffered another blow before the break as Suso was forced off injured, with the Spaniard clutching at his knee.
There was a renewed intensity about the Rossoneri at the start of the second half and Bacca sent a curling effort narrowly wide to underline their growing threat.
Bacca looked set to equalise in the 52nd minute, but his goal-bound shot from the heart of the penalty area struck team-mate Lapadula.
The Colombia international spurned an even bigger chance 10 minutes later, his tame penalty – controversially awarded after Paletta looked to have been fouled outside the box by Ionita – kept out by the impressive teenager Crosta, who was unable to repeat the feat when Lapadula stepped up.
Paletta's foul on Han ended his day prematurely and the North Korean thought he had won it for Rastelli's side late on, but his celebrations were cut short by the linesman's flag.
Then came Donnarumma's howler and Pisacane was the man waiting to seize the opportunity, sparking wild celebrations from the home side on a poignant day.