AC Milan claimed a dramatic 2-1 win at Siena to claim the final Champions League place on the last day of the Serie A season.
With Fiorentina beating Pescara 5-1 the pressure was on Massimiliano Allegri's men and they were out of the top three when Claudio Terzi gave Siena the lead in the 25th minute.
Milan captain Massimo Ambrosini and Siena's Christian Terlizzi were then both sent off for second bookable offences in the space of two minutes before Mario Balotelli and Philippe Mexes netted to hand Milan the win.
Balotelli had an early chance as he fired in from 25 yards but Gianluca Pegolo made a smart low save.
M'Baye Niang then should have put the visitors ahead as Robinho's low cross found him inside the six-yard box but he blazed over the bar.
It was all Milan at that point and Pegolo was called into action in the 21st minute as Robinho unleashed a curler from distance.
But they were punished for not taking their chances four minutes later as Alessandro Rosina's cross from the left found an unmarked Terzi who headed home.
Just before the half-hour mark Balotelli hit the bar with a header and moments later the former Manchester City man fired a long-range free-kick over.
Riccardo Montolivo also fired over two minutes before the break as Milan continued to be frustrated.
The visitors began the second-half as they had finished the first with Montolivo and Balotelli both firing over the crossbar again.
They managed to find the target in the 65th minute as Stephan El Shaarawy tried his luck from the edge of the box but Pegolo was equal to his effort.
Two minutes later El Shaarawy headed over the bar before Ambrosini was shown his marching orders after clattering into Adrian Calello.
And just a minute later Terlizzi followed him down the tunnel for his tackle on Giampaolo Pazzini.
No Milan player could get the vital touch on Mattia De Sciglio's inviting cross from the left as the Rossoneri pushed for an equaliser and Pegolo was forced into another save by Balotelli.
Nine minutes from time Allegri's men were rewarded for their dominance as Felipe was penalised for pulling Balotelli's shirt inside the box and the striker tucked the penalty low to Pegolo's left.
And the drama did not stop there as five minutes later Mexes tucked home his own rebound from close range to complete the comeback.