Ten-man AC Milan lost 2-1 at Cagliari in their last game of the Serie on Sunday after conceding a stoppage-time goal.
Fabio Pisacane scored three minutes into added time after Gianluigi Donnarumma failed to hold on to a free kick by Joao Pedro.
Joao Pedro had given Cagliari the lead 17 minutes in after being set up by Marco Borriello.
Gianluca Lapadula equalised for Milan from the penalty spot in the 72nd minute before Milan defender Gabriel Paletta was sent off after a second yellow card three minutes later.
Milan, who will enter the Europa League in the third qualifying round at the end of July, finish sixth.