Inter Milan came from behind to snatch the final Champions League place in their 3-2 winner-takes-all victory at Lazio.
The home side, who only needed to draw, were leading 2-1 at half-time after Adam Marusic and Felipe Anderson had scored either side of a Danilo D'Ambrosio effort.
But the game changed when Stefan de Vrij -- who has reportedly agreed a move to Inter for next season -- gave away a penalty from which Mauro Icardi levelled.
Senad Lulic was sent off for a second booking shortly afterwards and Matias Vecino headed home from a corner with less than 10 minutes remaining to seal a remarkable win.
There had been drama shortly before Icardi's equaliser when Inter were awarded a penalty for a push by Marusic, only for the Video Assistant Referee to overturn the decision.
Victory moved Inter level on points with Lazio, who had a significantly better goal difference, but head-to-head records are used in Serie A meaning Luciano Spalletti's men finished fourth.
"The Champions League has been our aim since the beginning of the season," Inter captain Icardi said after the match. "We were aware of our strength from the start and finally we did it -- after a crazy match."
Several Lazio players were in tears after the final whistle.
"We should have probably sealed the Champions League place earlier and not needed to do this in this last match," Lazio coach Simone Inzaghi said.
"Evidently it was destiny. A night like this will remain inside us for a long time."
The Associated Press contributed to this report.