Lorenzo Insigne opened the scored with a delightful strike from 30-yards out – catching Real ‘keeper Keylor Navas out.
The hosts responded well and levelled in the game when Benzema headed home past Pepe Reina inside the six-yard area.
Toni Kroos put Real ahead shortly after half-time before Casemiro scored one of the goals of the season five minutes later.
Insigne put Napoli ahead inside eight minutes
Real finished second behind Borussia Dortmund in Group F, and came into the game unbeaten in their last 18 games in all competitions.
The hosts came close to breaking the deadlock after just 20 seconds when Ronaldo cut the ball back to Benzema, whose first time shot was beaten away by Reina.
It was an end-to-end start to the contest in the Spanish capital and on eight minutes the visitors took the lead through a delightful piece of play.
Marek Hamšík slipped the ball through to Insigne, and the forward placed his early shot into the bottom corner – catching out Navas from 30-yards out.
Benzema levels for Madrid
Benzema could only glace Ronaldo’s cross wide of the post, but the French international did manage to make up for the missed effort six minutes later.
Carvajal crossed with the outside out his right boot and Benzema made no mistake after he headed home inside the six-yard area.
Madrid should have gone ahead in the game just before the half-hour mark when Luka Modrić helped the ball on through to Ronaldo.
The Portugal captain took the ball in his stride, but managed to blaze over the crossbar, with the goal gaping, from 12-yards out.
Madrid were continuing to put pressure on Napoli, who seemed content to absorb it, and went close three minutes before half-time.
Ronaldo, who broke down the flank, crossed early and Benzema flicked the ball under the approaching Reina and wide of the post.
Two goals in six minutes from hosts
Los Blancos come out after the break and took the game to their opponents and went ahead four minutes after the restart.
Ronaldo skipped easily past Kalidou Koulibaly before pulling the ball back to Kroos and the midfielder side-footed home from the edge of the area.
Marcelo struck just over the bar shortly after, but Napoli’s early goal looked just a distant memory after Los Blancos doubled their advantage on 54 minutes.
The ball broke to Casemiro fully 30-yards from goal and the Brazilian smashed a volley across goal and into the far corner for one of the goals of the tournament.
Madrid and Napoli continue Bernabéu
Real broke forward just after the hour mark, but after Benzema pulled the ball back to Ronaldo, the winger struck over inside the area – the end-to-end pattern continued.
Napoli created an opening two minutes later when former Madrid player Jose Callejon teed up Dries Mertens, but the Belgium international struck his first-time effort over the bar.
James Rodriguez found himself through after a reverse pass from Kroos, but Reina denied the Colombian with a fine reflex save.
Napoli had the ball in the net once more on 81 minutes when Callejon tapped home from close range, but the goal was ruled out for offside.
Madrid went close inside the closing stages, but Modrić struck over the bar before Marcelo tried to find the far corner with his a low effort.