Trailing to goals from Karim Benzema and Sergio Ramos, the Nerazzurri looked to have earned a point as Lautaro Martinez finished off a magnificent Nicolo Barella reverse pass, before Ivan Perisic calmly netted a second half equaliser.
Just as they were in the ascendency, Inter were undone by a fine finish from substitute Rodrygo late on, leaving them winless in Group B after three matches.
At the other end Inter squandered a rapid counterattack as Perisic brought a switched pass under control in the box and drew Thibaut Courtois out, before overhitting a cross to Barella with the goal gaping, and the midfielder was at a stretch as his header clipped the crossbar.
Moments later Martinez pounced on a loose ball in the box but his shot was too close to Courtois. With both sides making sloppy errors, Arturo Vidal was able to take control of the ball in midfield and rifle a vicious strike into the side netting.
As the hosts began to put the pressure on, they were gifted an opener by their former player Achraf Hakimi. The full-back’s dreadful backpass from the halfway line was intercepted by Benzema and he made no mistake in rounding the stranded Handanovic to slot home.
Just eight minutes later Real Madrid doubled their advantage and piled further misery on an Inter defence that failed to pick up Ramos from a corner, allowing the centre-back a free header to net his 100th goal for the club.
However the Nerazzurri halved the deficit immediately in some style, courtesy of a stunning Barella backheel on the volley to release Martinez, and the Argentine did well to fire in under pressure.
Inter came out in the second half on the front foot, with Barella finding space between the lines and Perisic’s follow up from a Marcelo Brozovic freekick well blocked after scrappy defending in the box.
Yet it ought to have been 3-1 on the hour mark as Rodrygo gave Real Madrid a spark from the bench, meeting Benzema’s squared pass on the edge of the box and slicing just wide.
That miss appeared to prove costly though as Inter completed their comeback at the other end. Vidal brought down a poor clearance and lofted the ball into the box for Martinez, who deftly nodded on for Perisic to coolly finish.
Having looked in complete control, Real Madrid were almost behind with a quarter of an hour remaining as the visitors missed two gilt-edged chances. After Martinez pounced on a sloppy Ferland Mendy touch to dart in and bend the ball just past the post, Perisic also broke clear but could only drill wide.
Just as Inter appeared set to turn the match on it’s head, they were stunned by a sucker punch by Rodrygo. The Brazilian stepped away from Vidal to thunder Vinicius Junior’s cross into the roof of the net with 10 minutes remaining, giving Handanovic no chance.
It ought to have been wrapped up soon after as Benzema was unmarked at the back post from Vazquez’s cross, but the Frenchman completely misjudged the cross from just yards out.
Real Madrid held out for victory though to seal a first Champions League win in six, whilst Inter remain rooted to the bottom of Group B at the halfway point.