Gerard Deulofeu spared AC Milan's blushes with a last-gasp goal, but at full-time it was their opponents Atalanta who were jubilantly celebrating the point from a 1-1 draw.
The result guarantees the Bergamo club's return to European competition after a 26-year absence as they cannot now be dislodged from fifth place over the last two games of the season.
Gian Piero Gasperini's men will play in the Europa League next year and still have ambitions of breaking into the top four. They were set on their way to closing to within two points of Lazio by Andrea Conti.
The Nerazzurro right-back was best placed to exploit Gianluigi Donnarumma's poor attempt to collect Leonardo Spinazzola's cross one minute before half-time, and Atalanta were deservedly ahead.
Milan's teenage goalkeeper Donnarumma spent the second half under siege and his colleagues eventually repaid him for his efforts when Deulofeu beat Atalanta stopper Etrit Berisha in the 88th minute. The on-loan Everton winger made it a fourth straight away draw for the ailing Rossoneri.