Frenchman Phillipe Mexes scored a late winner for AC Milan in a 2-1 comeback victory at Siena on Sunday which saved the Serie A giants' chances of appearing in next season's Champions League.
Milan were facing a fourth-place finish after falling behind to a 25th minute goal from Claudio Terzi.
However, after spurning several chances throughout the match in which both sides finished with 10 men, the seven-time European champions were given a lifeline when Mario Balotelli levelled from the spot in the 84th minute after being fouled in the box.
Mexes, one of two defenders at fault when Terzi was allowed space to head home his opener, then bundled the ball home from close range after seeing his initial effort blocked.
Milan finished third on 72 points behind second-placed Napoli (78) and recently-crowned champions Juventus, the latter two qualifying automatically for the Champions League.
Milan coach Massimiliano Allegri's job was reportedly in jeopardy if the former European giants failed to clinch a third-place finish.
Although Allegri has been linked with a move to Roma, he was given an indication by club CEO Adriano Galliani that his job at the San Siro is safe.
"Massimiliano Allegri can rest assured: in the past two years he's collected more points than Juventus," said Galliani.
Fiorentina were Milan's sole rivals for third spot, which offers qualification for the competition via a preliminary round.
But despite Adem Ljajic scoring a hat-trick in a 5-1 win over already-relegated Pescara, it wasn't enough to push the Florence-based side up to third.
Fiorentina finish fourth, two points adrift of Milan, and earn an automatic Europa League place, in which they will be joined by Udinese following the northerners' superb 5-2 away win at Inter Milan.
Asked if the team were bitter, Fiorentina coach Vincenzo Montella said: "No, we shouldn't be feeling that. We will be going on holiday feeling proud of what we've achieved this season."
Inter's European hopes faded a month ago after injuries and a series of consequent setbacks left Andrea Stramaccioni's team out of the running for the European places.
Lazio, likewise, finished the season on a low note after succumbing to a 75th minute goal from Cagliari's Daniele Dessena.
Along with Roma's superb 2-1 win over Napoli, Lazio dropped to seventh place, one place and one point behind their city rivals.
Roma midfielder Marquinho opened the scoring for Aurelio Andreazzoli's men in the 47th minute and striker Mattia Destro doubled the hosts' lead 11 minutes later.
The only silver lining around Napoli's sixth defeat of the season was the late consolation goal scored by Edinson Cavani, which took the Uruguayan striker's league-leading tally to 29 in 34 appearances this season.
However, it may well have been the Uruguayan's last goal for the club, who are expected to accept an offer for the striker who has been linked with a move to Real Madrid or England's Premier League.
Napoli coach Walter Mazzarri, meanwhile, had been widely expected to leave the club and he confirmed he will take up a fresh challenge elsewhere.
"My cycle at Napoli has come to an end. I need a change of scene," said Mazzarri, who like Allegri has been tipped to replace Aurelio Andreazzoli.
"It's been four fantastic years, I thank all the lads and everyone who's been with me."