Atalanta came from behind to beat Sassuolo and qualify for the Champions League for the first time, with Inter joining it after a win that relegated Empoli from Serie A.
Sassuolo's Domenico Berardi threw a spanner in the works for Atalanta when he struck a 19th-minute opener in Bergamo but Duvan Zapata bundled home his 23rd goal of the season to restore parity.
Sassuolo was reduced to 10 men at half-time when Berardi objected to Marten de Roon's reaction after touching foreheads with Francesco Magnanelli and was shown a red card.
Alejandro Gomez put Atalanta back in front eight minutes into the second half and substitute Mario Pasalic put the result beyond doubt after the hour mark, with Magnanelli dismissed for a second yellow late on.
Gian Piero Gasperini's side finished third and was joined in the top four by Inter, which defeated Empoli 2-1 thanks to Radja Nainggolan's 81st-minute strike.
Hamed Junior Traore cancelled out Keita Balde Diao's opener after Mauro Icardi saw a penalty saved by the impressive Bartlomiej Dragowski, but Nainggolan scored the goal that denied rivals AC Milan a place in the top four.
Keita was given a second booking for a foul on the backtracking Dragowski, who went up for a corner, as Marcelo Brozovic scored from close to the halfway line following a video review, while Empoli's back-up keeper Filippo Perucchini was dismissed from the bench for his remonstrations.
That result and Genoa's 0-0 draw at Fiorentina sent Empoli straight back down to Serie B, while Milan was consigned to the Europa League for the third straight season despite a 3-2 win at SPAL.
Franck Kessie set up the opener for Hakan Calhanoglu and then struck a double, the second of which came from the spot after Francesco Vicari and Mohamed Fares wiped out the Rossoneri's two-goal lead.
Roma beat Parma 2-1 in Daniele De Rossi's final match but had to settle for sixth, with all of their top-four rivals also triumphing.