Alvaro Morata ensured the second leg finished with the same scoreline as the first by tapping in a rebound in stoppage time.
Naples: Two quick-fire goals saw Real Madrid survive an early scare to win 3-1 at Napoli on Tuesday and reach the Champions League quarterfinals for a seventh successive time.
Trailing 3-1 from the first leg, Dries Mertens had given Napoli hope with his 24th-minute strike. But Sergio Ramos headed in a Toni Kroos corner early in the second half and had another header deflected in by Mertens six minutes later to effectively end the contest.
Alvaro Morata ensured the second leg finished with the same scoreline as the first by tapping in a rebound in stoppage time after Pepe Reina had denied Cristiano Ronaldo.
Napoli were left to rue their first-half profligacy which saw Mertens hit the post. Ronaldo, who is two goals short of becoming the first player to score 100 times in European competition, was also denied by the woodwork.
Needing to win by at least two clear goals, Napoli applied the pressure right from the start, with Mertens having a shot deflected over the bar in the opening minute.
Marek Hamsik also fired inches wide, while Lorenzo Insigne had a 30-yard (meter) snapshot turned around the post by Keylor Navas.
Madrid appeared to have weathered the early storm and Gareth Bale threatened but the Spanish side was undone by a moment of brilliance from Napoli. Insigne and Hamsik combined, with the latter threading a delightful pass for Mertens to rush into the area and slot into the bottom right corner.
Madrid had scored in their past 46 matches and they levelled six minutes after the break.
Hamsik gave the ball away in the middle of his own half and Elseid Hysaj was forced to head out the danger at the far post, with Ramos heading in the resulting corner.
Madrid doubled their lead from another corner to all but extinguish Napoli's hopes, before Morata rounded off the scoring.