Atletico Madrid grabbed a place in the last 16 of the Champions League as Antoine Griezmann scored one goal and had a key role in the two others as the Spanish side beat Porto 3-1.
The win in northern Porto coupled with AC Milan's 2-1 defeat to a second-string Liverpool side at the San Siro was enough to send Diego Simeone's side through as the second-placed team in Group B despite starting the day bottom.
Yannick Carrasco complicated Atletico's task by getting sent off with 20 minutes to go for grappling Otavio to the ground in a touchline melee.
Three minutes later, the numbers were evened up as Porto had Wendell red-carded after French referee Clement Turpin adjudged he had struck an Atletico player.
Porto had two golden chances to score, but Mehdi Taremi wasted both. First he was denied by a brilliant one-handed save by Jan Oblak in the first half and then he side-footed over the bar in the second from a good position.
After a largely sterile first half, all the goals came in a frenetic second period.
Against the run of play, Atletico went ahead on 56 minutes when Griezmann was left unmarked by Otavio and nonchalantly tapped in at the back post from an in-swinging corner.
Ater the bad-tempered period that produced two red cards, Griezmann created the second goal by drawing two Porto defenders on the touchline before brilliantly slipping the ball to the charging Angel Correa who kept his head to slide a shot past 'keeper Diogo Costa. Griezmann was involved again as Porto, with players committed in attack, were caught out and the French striker scuffed his shot but Rodrigo De Paul made no mistake two minutes into stoppage time.
Read more: Women’s football league to resume from Saturday
Sergio Oliveira scored from the penalty spot for Porto in the sixth minute of injury time but the long faces on the Portuguese side's bench told the story of the match.