Toni Kroos and Casemiro scored fantastic goals in the second half, following up Karim Benzema's equalizer, and Real Madrid will carry the two-goal edge into the second leg in Naples next month.
It started off quite well for Napoli, though, as Lorenzo Insigne stunned Real Madrid early on with a heads-up play. Catching Keylor Navas off his line, the Napoli forward curled a long-range effort by the Costa Rica goalkeeper and in to shock the crowd at Estadio Santiago Bernabeu and give Napoli an away goal in the eight minute.
Benzema struck back for Real Madrid though, heading home after a perfect cross from Dani Carvajal to make it 1-1 in the 18th.
Real Madrid took its first lead of the day shortly after halftime, with Ronaldo beautifully setting up Toni Kroos for the go-ahead strike in the 49th minute.
That lead grew to 3-1 on an unbelievable hit from Casemiro, who had a clearance bounce his way. He unleashed a ferocious one-time volley by Pepe Reina to extend the advantage in sensational fashion.
|Real Madrid have now won 34 of their 39 Champions League games at the Bernabeu|
Real Madrid came from a goal down to beat Napoli in the first leg of their Champions League last-16 tie.
The visitors took the lead after Keylor Navas was caught off guard by a superb Lorenzo Insigne strike inside eight minutes.
Karim Benzema headed the equaliser past Pepe Reina from Dani Carvajal's cross 11 minutes later.
Toni Kroos put the hosts ahead early in the second half, before a stunning volley from Casemiro sealed the win.
Napoli will host the second leg on 7 March, with a place in the quarter-finals at stake.
Another game without a goal for unselfish Ronaldo
Cristiano Ronaldo has now gone 523 minutes without a Champions League goal - his longest drought in the competition at Real Madrid.
The 32-year-old missed a golden opportunity midway through the first half to give Real a 2-1 lead, but he blasted his shot over the bar from 12 yards out.
Ronaldo's performance was far from selfish and he was lively from the off. He created a chance after just 23 seconds with his darting run finding Benzema, who forced a one-handed save from Reina.
Although Ronaldo failed to hit the target during the game, his hard work paid off when he pulled the ball back to Kroos to give the hosts the lead early in the second half.
That makes it five assists in seven Champions League appearances this season - his most in a season in the competition for Real Madrid.
Superb strikes showcase Europe's top talent
Insigne set the standard with his impressive early goal. Marek Hamsik ripped apart the Real defence with the through ball and Insigne made no mistake in converting.
He spotted Navas off his line and curled the opener into the bottom corner from 35 yards out with Napoli's only shot on target in the first half.
But Casemiro stole his thunder with a world-class finish to wrap up the win for Real, leaving Reina with no chance with a long-range volley.
The Brazilian has had 16 attempts in the Champions League, scoring only twice with both goals coming from outside the box.
Carvajal delivered a sumptuous cross with the outside of his boot to tee up Benzema for the equaliser and his 51st goal in Europe.
His powerful header sees him move up to fifth in the competition's all-time leading scorers, overtaking Thierry Henry.
Ronaldo tops the list with 95 goals, followed by Lionel Messi (93), Raul (71) and Ruud van Nistelrooy (56).
What the managers said
Real Madrid boss Zinedine Zidane: "We played a great game - it was a shame about the Napoli goal but we rectified things, scored ourselves and turned the game on its head and I think it was the right result.
"We'll go there to a difficult ground where we'll suffer and it is still an open game. We need to go there and finish it off with our 3-1 advantage."
Napoli boss Maurizio Sarri: "In the second leg we'll try to overturn the situation. We need no mistakes and to create more chances. I still believe we can make it. I'm confident.
"I've told my players not to give up and the same counts for me. We need to be stronger than ever."
Omens are good for Real - the stats you need to know
- Real Madrid have progressed from each of their last eight Champions League ties in the last 16 or beyond when they've won the first leg.
- Napoli have been eliminated on each of the previous four occasions they have lost the first leg of a last-16 tie in European competition.
- Karim Benzema netted in his fourth consecutive Champions League game (five goals), equalling his previous longest streak (2010-11 and 2014-15).
- Cristiano Ronaldo has provided five assists in the Champions League in 2016-17, his most for Real Madrid in a single season of the competition.
- Real Madrid have not kept a clean sheet in any of their last eight CL games - their longest run since March 2013 (11 games).