The unfancied Dutch side were 2-1 down from the first leg heading into what appeared a daunting return meeting at the Bernabeu in the last 16 tie against Santiago Solari's men.
But the visitors dominated the game and claimed a historic 4-1 win on the night, sending them through to the quarter-finals of the competition and ending Madrid's spell of dominance that had seen them win the last three titles in a row.
There was, however, an incident of controversy, with Ajax's third goal having to be referred to VAR for what proved a lengthy period of at least two minutes after Dusan Tadic had fired past Thibaut Courtois and into the top corner of the net.
Prior to the former Southampton winger's strike, Mazraoui had hunted down the ball that was heading out of play by the touchline and stretched to nudge it back inside.
It was, however, an extremely tight call with it proving difficult to outright confirm if part of the ball had stayed in play or, indeed, rolled past the line.
The officials ruled in favour of Ajax and the goal stood, with Mazraoui admitting afterwards that he knew it was going to go to a VAR check as soon as the ball hit the net.
He told AT5: "I made that tackle and thought: 'now I should keep the ball in play, so Real would think it's out and stop playing'.
"I didn't know whether it stayed inside [the line] or not, but when we scored after that, I knew the VAR would double check that moment.
"In the end it was a goal. Great. We've made some history. We made Amsterdam proud. It's a humiliation for Real Madrid and a big win for us."