Fiorentina crushed Pescara 5-1 but remained in fourth spot and will play in the Europa League next season.
Mario Balotelli leveled for Milan from the penalty spot six minutes from fulltime, and Philippe Mexes scored the winner three minutes later.
Both teams were contentiously 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.
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.
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.
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.