MILAN — AC Milan secured third spot and a place in the Champions League after coming from behind to win 2-1 at Siena on Sunday in the final Serie A round of the season.
Fiorentina crushed Pescara 5-1 but remained in fourth spot and will play in the Europa League next season.
Mario Balotelli leveled for Milan after it was contentiously awarded penalty six minutes from fulltime, and Philippe Mexes scored the winner three minutes later.
Both teams were reduced to 10 men for the final 20 minutes after Milan captain Massimo Ambrosini and Siena defender Christian Terlizzi were sent off within moments of each other.
Udinese took the second Europa League berth after winning 5-2 at Inter Milan for its eighth successive victory.
Milan's achievement is impressive considering numerous top players, including Zlatan Ibrahimovic and Thiago Silva, left the club in the last offseason.
The team was 15th in October but has charged up the standings, losing only three times in the league since. It went into the final round of matches protecting a two-point lead over Fiorentina, with both sides visiting already-relegated clubs.
"It was normal to be a little tired, above all psychologically, after this incredible fightback from a poor start to the campaign," Allegri said. "Tonight we ran into a great goalkeeper and hit the woodwork, while we were a little too hasty and felt the tension of the occasion.
"I want to thank the players and the fans, who deserved a night like this. During a year you get some penalties that are dubious and are turned down, others that are definite. We were two points ahead going into the weekend, our destiny was in our hands, so we got the victory."
Allegri's future remains uncertain, with speculation of a move to Roma after criticism from owner and former Italian Premier Silvio Berlusconi.
"I certainly can't walk away as I have a contract, so it is their decision," he said. "Right now, talking about the future is too early. The season has just ended, let me enjoy this victory. In three years, the president has given me faith and could easily have fired me this season after the first eight games."
Siena goalkeeper Gianluca Pegolo denied Robinho and Balotelli in the opening minutes, and did even better to palm Robinho's fierce strike round the post in the 21st minute.
Siena took the lead when Claudio Terzi was left unmarked to head in Alessandro Rosina's pass over the defense in the 26th.
Milan coach Massimiliano Allegri brought on Giampaolo Pazzini and Stephan El Shaarawy for M'Baye Niang and Antonio Nocerino in the second half.
However, Ambrosini was sent off for a second booking after a sliding tackle on Adrian Calello in the 69th. Siena was also harshly reduced to 10 men when Terlizzi was shown a second yellow for clattering into Pazzini.
Milan was awarded a penalty when Dias Felipe hauled down Balotelli. The Italy striker has never missed a penalty in his professional career and he duly converted his 23rd from the spot. He has now scored 12 goals in 13 games for Milan.
The crucial goal came three minutes from time. Pegolo saved the Milan defender's original shot but lost the ball and Mexes reacted to toe-poke it home.
Fiorentina has also had a fantastic campaign after an offseason of change following a disastrous season in which it finished 13th, just 10 points clear of the relegation zone.
Last season, Delio Rossi was fired as Fiorentina coach for punching forward Adem Ljajic during a match.
And it was Ljajic that was again the star as he notched a hat trick to help Fiorentina to a comfortable — but ultimately meaningless — victory.
Matias Fernandez scored his first Serie A goal and Stevan Jovetic grabbed the other. Debutant Marco Vittiglio scored a consolation for Pescara.
"Are we bitter at how it finished? No, we should be proud," Fiorentina coach Vincenzo Montella said. "We tried and believed right to the end. We ought to be proud that we pushed Milan to the finish line. I thank the lads for this fantastic campaign. We just lacked the cherry on the cake."
It took Udinese just 39 seconds to open the scoring against Inter as Giampiero Pinzi was given too much space by Juan Jesus, and he burst forward to score past former teammate Samir Handanovic.
Udinese went 2-0 up in the 10th minute when an unmarked Maurizio Domizzi headed in Antonio Di Natale's cross.
Inter reduced the deficit less than two minutes later, however, when Juan Jesus's shot squirmed under Udinese goalkeeper Zeljko Brkic.
Di Natale scored a stunning goal moments from halftime, curling the ball in off the far post for his 23rd strike of the season.
Udinese extended its advantage further when Gabriel Silva lifted the ball over the onrushing Handanovic in the 52nd.
Tommaso Rocchi gave Inter hope shortly after the hour mark when he slotted home Rodrigo Palacio's cross.
However, two minutes later Luis Muriel beat the offside trap and took advantage of a mix-up between Handanovic and teammate Yuto Nagatomo to score his side's fifth.
Udinese finished four points above sixth-place Roma, which beat runner-up Napoli 2-1 after goals from Marquinho and Mattia Destro.
League top-scorer Edinson Cavani grabbed one back for Napoli with his 29th goal of the season.
Napoli coach Walter Mazzarri later announced his departure from the club after four years in charge.
Lazio finished a point behind Roma after losing 1-0 at Cagliari, following Daniele Dessena's header. Torino twice came from behind to draw 2-2 at home to Catania, while Parma beat already-relegated Palermo 3-1.
Earlier, Cyril Thereau scored twice, including a late equalizer, as Chievo Verona drew 2-2 at Atalanta. Bologna was held to a scoreless draw by Genoa.