Zlatan Ibrahimovic recently tested positive for covid-19 and was thus missing in the match squad that would take Milan to the Europa League.
They also lined up with a rather b-stressed team against Rio Ave, which finished fifth in the Portuguese league last season.
After a goalless first half, they still took the lead when the Belgian Alexis Saelemakers shot in 1-0 after a corner.
But with barely 20 minutes left to play, the equalizer came.
After a short tussle with the defender, Francisco Geraldes finally tucked the ball home. Gianluigi Donnarumma took his place.
The match was awarded and already after one minute Gelson ran through the Milan defense and put 2-1.
It also looked to be the winning goal, but in the very last seconds of extra time, Toni Borekovic took his hand in the penalty area.
Borekovic received his second yellow card and Milan received a penalty which Hakan Calganoglu managed nicely to 2-2.
The penalty was dramatic in the rain and wind in Vila do Conde.
It took until the eighth penalty round before the first miss came and then it was the Italians Lorenzo Colombo who shot over the crossbar.
Hill Nelson Monte had a chance to become a hero, but his penalty went into the post.
In the tenth penalty round, both teams missed again and this time it was the team's goalkeepers who shot.
Both teams also missed the round after.
In the end, the Dane Simon Kjaer became a hero when he decided with the team's twelfth penalty and Milan will thus play in Europe this autumn.
For Rio Ave, the European adventure is over for this time.