Karim Benzema and Marco Asensio on target in Real Madrid victory
Hakim Ziyech had equalised for the home side in between.
Karim Benzema and Marco Asensio were on target as Real Madrid secured a 2-1 win over Ajax in the Champions League last-16 first leg in Amsterdam.
But the reigning champions, seeking a fourth straight title, were given a major scare by the only team left in the competition who had to come through qualifying.
Four-time winners Ajax, in the knockout stages for the first time in 13 years, dominated for long spells.
In a vibrant display they hit the woodwork, tested Thibaut Courtois frequently and had a goal ruled out by the video assistant referee before Benzema struck.
Hakim Ziyech then equalised for Ajax, only for substitute Asensio to grab the winner three minutes from the end.
Real travelled to Holland full of confidence after a 3-1 win against Atletico Madrid at the weekend, their sixth victory in a seven-game unbeaten run.
Moments later Ajax threatened and Noussair Mazraoui was played in by Dusan Tadic only to screw his shot across goal and wide.
Onana was in action again after 15 minutes to tip over a fierce angled drive from Brazilian teenager Vinicius Junior.
Ajax were by now well on top and another slick passing move put Ziyech through on goal but Courtois came out well to block.
The hosts thought they had taken a deserved lead when, from the corner, Courtois made a mess of claiming a header and Nicolas Tagliafico nodded in the rebound.
Early in the second half Benzema tested Onana with a low shot on the tun, before Ajax broke down the other end and David Neres fired too close to Courtois.
But just before the hour mark Benzema made the breakthrough with his 60th Champions League goal on his 450th Real appearance.
Ajax were not finished, though, and with 15 minutes left they sliced Real open again with Ziyech converting a low cross from Neres.
However, Asensio converted the winner when he met a stunning delivery from Dani Carvajal at the far post.