The Primera Division champion dominated proceedings in the opening hour, and the away side was unable to get back into the game
Cristiano Ronaldo opened the scoring early in the game after some good work from Karim Benzema, before Jose Callejon doubled the hosts' lead around the half-hour mark. Kaka then made it three after the break, only for Derk Boerrigter to peg one back after 60 minutes of play. However, Callejon restored Madrid's three-goal lead in the dying minutes of the game.
The Blancos started the match with attacking intentions and seemed to open the scoring after only seven minutes of play when Benzema tapped home from close range, only to see the referee disallow the goal for offside. Shortly after, Madrid again threatened as Fabio Coentrao hit the post with a powerful shot from the left.
Madrid remained the better side of the two and did eventually break the deadlock in the 13th minute. Benzema escaped the offside trap after a fine pass from Luka Modric, and then kept his calm to set up Ronaldo, who found the empty net with a confident shot from inside the area.
Benzema continued to cause the Ajax defense all kinds of trouble with his intelligent movement and came close to adding his name to the score sheet after being set up by Kaka, but Kenneth Vermeer reacted alertly and denied the Frenchman.
The Ajax goalkeeper was beaten in the 28th minute after a superb counterattack, though. Modric bullied Siem de Jong off the ball inside his own half, before unleashing a magnificent pass over the top of the Ajax defense for Callejon, who superbly controlled the ball and calmly slotted home.
The Eredivisie champion, meanwhile, failed to really threaten at the Bernabeu, with Viktor Fischer's low shot after an individual action as its only noteworthy feat of the opening 45 minutes.
Jose Mourinho's men immediately charged forward again in the second half, and were rewarded within five minutes when Kaka showed his class. The Brazilian picked up a pass from Ronaldo inside the Ajax half, dribbled a few yards, and then beat Vermeer with a placed shot from 20 yards out.
Ajax pegged one back at the hour mark after some poor goalkeeping from Antonio Adan. The 25-year-old failed to collect a cross from the left after rushing off his line, and Boerrigter had no trouble finding the empty net. Adan made amends for his error some five minutes later, though, when he saved Boerrigter's free kick from the edge of the box.
Danny Hoesen then should have helped Ajax further back in the game after shaking off Ricardo Carvalho, but the young striker wildly blasted the ball over the bar from a dangerous position.
The hosts would eventually restore their three-goal lead after some good work from Alvaro Morata, though. The youngster went by his direct opponent down the right, and then sent in a perfect cross for Callejon, who doubled his personal tally with a good header.
Madrid has finished second in its section with 11 points from six games. Its resumes domestic action at the weekend away against Valladolid.
Ajax has qualified for the Europa League round of 32 following Tuesday's results as it has to settle for third place in Group D. Its next match is the Eredivise game at home against Groningen on Saturday.