Real Madrid coach Jose Mourinho has marked his 100th Champions League game with a 1-1 draw at Manchester City that sent his side into the last 16 at City's expense.
City had to win to stand any chance of going through, so although Sergio Aguero's 73rd-minute penalty cancelled out Karim Benzema's early opener, the host went out in the group phase for a second successive season.
Madrid had Alvaro Arbeloa sent off, but with eight points - three less than Group D leaders Borussia Dortmund - they cannot be caught by either Ajax or City, who had not lost in their 19 previous European home games.
The English champions trail Ajax by a point and therefore must win at Dortmund in their final group fixture and hope the Dutch side lose in Madrid if they are to secure the consolation prize of a Europa League berth.
Mourinho, the youngest coach to reach the 100-match milestone, is now a step closer to delivering an elusive 10th European Cup to the Spanish champions, who have already fallen eight points off the pace in La Liga.
City coach Roberto Mancini elected to deploy a three-man defence at the Etihad Stadium but the home side's defenders did not seem comfortable with the system and Madrid were quick to profit.
In the 10th minute, Angel di Maria was given space to cross from the right and his centre found the unmarked Benzema, who cantered in behind Maicon to beat Joe Hart on the volley from close range.
With Maicon and Pablo Zabaleta on the pitch, the right side of City's defence should have been secure but Cristiano Ronaldo found plenty of room there.
Roundly booed on his first appearance in the city since leaving Manchester United in 2009, Ronaldo twice reached the byline on Madrid's left, only for Sami Khedira to put both of his crosses wide.
City changed their shape, with Zabaleta switching to left-back in a conventional back four but they were unable to make inroads into the Madrid area.
The hosts improved early in the second period, with Aguero heading over from Maicon's cross and David Silva shooting at Casillas after Arbeloa's clearance came straight to him.
Carlos Tevez was introduced on the hour but still fortune eluded City, with Aguero's close-range volley miraculously kept out by Casillas in the 64th minute.
The game turned eight minutes later, after Arbeloa was shown a second yellow card for a push on Aguero inside the Madrid area.
Just as he had done in Saturday's 5-0 win over Aston Villa, Aguero converted the spot-kick, and City's last-16 ambitions appeared revived.
Tevez fired in a low shot that Casillas comfortably held, but despite five minutes of added time that prompted an incredulous reaction from Mourinho, there was no late drama.