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.
Substitute Alvaro Morata added another in stoppage time against deflated opponents to give Real a 3-1 win that 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."
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 that started last year's final which 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 sent Cristiano Ronaldo 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 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.