Napoli, trailing 3-1 from the first leg of the round of 16 tie, looked more than capable of overturning the deficit as they dominated the first half and took the lead through Dries Mertens in the 24th minute.
Barcelona plot 'miracle' comeback against PSG
But with Real wobbling, Ramos popped up to head an equaliser early in the second half and he produced another header six minutes later which deflected off Mertens and into the net in the 57th minute pretty much seal the deal for the Los Blancos.
Substitute Alvaro Morata added another in the stoppage time against deflated opponents to give Real a 3-1 win which sent them into their seventh successive Champions League quarter-final by a deceptive 6-2 aggregate score.
"We did really well for the first 45 minutes but the two goals early in the second half took the wind out of our sails," said Napoli coach Maurizio Sarri. "Because of that, we weren't able to maintain the same intensity in the second half."
Real won't relax against Napoli: Zidane
Backed by a fervent crowd, Napoli made a fast and furious start and peppered the Real goal with shots in the opening 10 minutes.
They repeatedly carved open Real's defence with quick, clever angled passing and superb running off the ball.
One such move produced their opening goal when inspirational captain Marek Hamsik laid a perfectly-weighted first-time pass into the path of Mertens who lost his marker and placed his shot wide of Keylor Navas.
Real, fielding the same line-up which started last year's final when they won on penalties against Atletico Madrid, were being totally outplayed, although they nearly snatched an equaliser against the run of play.
Karim Benzema's pass came to Cristiano Ronaldo, who was sprinting between the Napoli defenders and past Pepe Reina, but the Portuguese forward fired his shot against the foot of the post.
Napoli also hit the woodwork with a shot on the turn by Mertens after Allan's pass was deflected into his path.
The hosts failed to begin the second half with the same intensity, however, and quickly paid the price after Hamsik uncharacteristically gave the ball away in midfield.
The move ended with Real winning a corner which Toni Kroos delivered perfectly for Ramos to rise above the Napoli defence and head the ball in to silence the crowd in the 51st minute.
Six minutes later, Ramos struck again from another corner, although this time the ball took a deflection of Mertens and UEFA awarded an own goal against the Belgian.
Faced with a hopeless task, Napoli completely lost their momentum and Real coasted through the rest of the game, Morata snapping up a rebound for the third goal.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ