The Dutch giants put in a strong display against the Primera Division leaders, but saw their Champions League ambitions come to an end following some shocking refereeing errors
Jose Callejon gifted Madrid the lead early on with a calm finish after being set up by Kaka. Gonzalo Higuain then showed his class as he made two for the guests in the closing stages of the first half. Callejon again escaped the offside trap well into stoppage time to add a third.
Ajax thought it had equalized twice, but goals from Nicolas Lodeiro and Miralem Sulejmani were wrongly disallowed.
The away side enjoyed the majority of possession in the opening stages of the game, and deservedly opened the scoring in the 14th minute. Kaka set up Callejon with a brilliant pass over the defense and the former Espanyol star kept his calm to slot the ball past the Ajax goalkeeper from inside the area.
Karim Benzema then came close to doubling Madrid's lead after a good individual action, but the Frenchman's low shot was kept out by Kenneth Vermeer.
Ajax then took over the initiative and the Amsterdam side thought it had restored parity in the 31st minute. Antonio Adan failed to hold on to Gregory van der Wiel's shot and Nicolas Lodeiro was alert to head home the rebound. Nevertheless, the assistant referee waved his flag and the goal was wrongly disallowed.
The refereeing trio again got it all wrong hardly minutes later when Ajax again found the net, this time via Miralem Sulejmani. Nevertheless, the goal was again wrongly disallowed as the Serbian was adjusted to be in an offside position when he deflected Vurnon Anita's shot past the shot stopper.
The Eredivisie giants were dealt yet another huge blow in the 41st minute. Higuain escaped the attention of Daley Blind after a superb Benzema pass and the Argentine showed good control before doubling Madrid's lead with a calm finish.
Ajax continued to push forward after the interval and really should have pegged one back via Jan Vertonghen. Nevertheless, the Belgian center back headed just wide from six yards after a corner kick from the right.
Minutes later, the Dutch champions again came close to making it 2-1, but Sulejmani's delicately lofted shot came back off the crossbar, before the Madrid defense cleared the ball into safety.
Real Madrid didn't create any clear cut chances in the second half, but it tried its luck from long range a number of times. However, both Esteban Granero and Xabi Alonso failed to really worry Vermeer between the sticks.
Callejon poured even more salt in Ajax's wounds well into stoppage time as he again beat the offside trap before rounding Vermeer and doubling his personal tally.
Real Madrid has won Group D with a perfect score of 18 points from six games, while Ajax has to settle for Europa League action as the section's No. 3 on goal difference.
The Spaniards resume domestic action on Saturday when they take on archrival Barcelona at the Santiago Bernabeu, while Ajax's next match is the Eredivisie game away against minnows RKC on Sunday.