A late Rodrygo strike for Real Madrid was enough to see off the stern challenge of Inter and clinch a 3-2 home win which blows their Champions League group wide open.
Madrid had raced into a two nil advantage, with Karim Benzema taking advantage of a poor Achraf Hakimi backpass to slot into the empty net.
And captain Sergio Ramos made it two minutes later, powering home a superb header to give his side an excellent advantage.
But a sublime team goal involving a backheel flick from Nicola Barella allowed Lautaro Martinez to slot home and bring the Nerazzurri back into the game.
And when Ivan Perisic bundled home the equaliser in the second half it looked as if Inter were in the ascendency and could go on to win it.
But two of Zinedine Zidane's substitutes, Vinicius Jr and Rodrygo, combined to allow the latter to lash his shot into the roof of the net and secure an important three points.
Madrid had already lost to Shakhtar and drew away with Borussia Monchengladbach in the group, and so the three points were vital to their chances of qualification.
Yellow card for Thibaut Courtois.
Substitute in, Radja Nainggolan.
Substitute out, Arturo Vidal.
Yellow card for Casemiro.
Assist given by Vinícius Júnior.
Goal by Rodrygo.
Substitute in, Roberto Gagliardini.
Substitute in, Alexis Sánchez.
Substitute out, Nicolò Barella.
Substitute out, Ivan Perišić.
Substitute in, Luka Modrić.
Substitute out, Toni Kroos.
Yellow card for Nicolò Barella.
Assist given by Lautaro Martínez.
Goal by Ivan Perišić.
Substitute in, Vinícius Júnior.
Substitute in, Rodrygo.
Substitute out, Eden Hazard.
Substitute out, Marco Asensio.
Yellow card for Federico Valverde.
Yellow card for Marcelo Brozović.
Yellow card for Ferland Mendy.
Yellow card for Arturo Vidal.
Assist given by Nicolò Barella.
Goal by Lautaro Martínez.
Assist given by Toni Kroos.
Goal by Sergio Ramos.
Goal by Karim Benzema.