Atletico Madrid's chances of reaching the Champions League last 16 were dealt a hammer blow on Wednesday after a 1-0 defeat by AC Milan left them needing to win at Porto in their final game in Group B.
A scrappy contest at the Wanda Metropolitano looked set to end goalless until Milan substitute Junior Messias headed home a dramatic winner in the 87th minute to leave Atletico staring down the barrel of an early exit.
Messias' goal not only means Atleti will need a victory instead of a draw in Porto on December 7 but it also brings Milan back to life, as they sit just a point behind Porto ahead of their closing match against Liverpool at the San Siro.
Atletico Madrid are level on points with Milan but beneath them on goal difference, with qualification even to the Europa League now far from certain.
All but two of Atleti's previous 11 Champions League group appearances have seen them reach the last 16 while Milan are participating at this stage for the first time since 2014.
But Milan deserved their late winner, after showing far more ambition in a game that Atleti contributed very little to in any creative sense.
Both teams came in without the assurance of recent victories, with Milan, second in Serie A, losing to Fiorentina last weekend on the back of a draw against Inter.
Atletico sit fourth in La Liga and have endured a mixed start to the season, from which the biggest doubts have arisen around an increasingly leaky defence. Their win over Osasuna on Saturday was only their second in seven matches.
Their best chance of the first half came in the third minute as Yannick Carrasco crossed and Rodrigo de Paul's attempted finish brushed the outside of the post.
The rest of the opening 45 minutes was short on quality, with both teams let down by a lack of precision in the final third.
Milan, though, were the chief aggressors and while Atletico allowed frustration with the referee to grow, their biggest problem was escaping the Milan press, which for long spells contained them in their own half.
Theo Hernandez, who came through the youth set-up at Atletico only to leave for Real Madrid in 2017, for which he was consistently whistled throughout, perhaps had Milan's clearest opportunity but he lashed wide at the far post.
Milan were still the more cohesive team early in the second half, with Simon Kjaer heading over from a crossed free-kick.
Diego Simeone brought on Angel Correa and Renan Lodi while Stefano Pioli introduced four substitutes, including the 40-year-old Zlatan Ibrahimovic.
Two of them combined to create a golden chance in the 71st minute, Messias freed down the left and pulling back for Tiemoue Bakayoko eight yards out but his finish was blocked by the right knee of Stefan Savic.
Atletico were wilting and Milan sniffed a winner. Ibrahimovic was slipped through but denied by a brilliant left-handed save by Jan Oblak and if that was a warning, Atletico failed to heed it, because moments later Messias headed in.
Franck Kessie hooked a superb left-footed cross into the middle, where Messias found a gap three yards out. The Milan bench sprawled onto the pitch in celebration.