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.
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 win an automatic Europa League place, in which they will be joined by Udinese following the northerners' superb 5-2 win away to Inter Milan.
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.