Premier League champion Man City dodged elimination when Sergio Aguero's 74th-minute goal completed a comeback started by Yaya Toure after Ajax had taken a 2-0 lead by the 17th minute.
The action continued after the final whistle when coach Roberto Mancini and several players surrounded Danish referee Peter Rasmussen to argue that Mario Balotelli should have been awarded a penalty in a last desperate attack. Aguero had also had a late strike disallowed for offside.
"The referee and the linesman were really poor. It was a penalty and it was a goal," Mancini told British broadcaster ITV.
Madrid twice trailed against group leader Borussia Dortmund and relied on Mesut Oezil to level in the 89th minute. With two games left, Dortmund has eight points, the Spanish giant has seven and Man City — last, with just two points — must beat both to have a chance of advancing.
Zlatan Ibrahimovic lifted Paris Saint-Germain toward the last 16 by creating all the goals in a 4-0 victory over a poor Dinamo Zagreb team. Group leader FC Porto progressed with two games to spare by drawing 0-0 at Dynamo Kyiv.
Malaga advanced to the next round despite conceding its first goal, with Milan needing Alexandre Pato's 73rd-minute header for a 1-1 draw. Anderlecht beat Zenit St. Petersburg 1-0.
Arsenal also wasted a two-goal lead in the first half on the road to draw 2-2 with Group B leader Schalke. Also in the group, Olympiakos beat last-place Montpellier 3-1.
Mancini, who was rewarded for winning the English title with a five-year contract, will do well to avoid a second straight group-stage exit.
Ajax exploited slack defending at corners when Siem de Jong struck with a shot from a tight angle in the 10th and the captain followed up with a powerful near-post header in the 17th.
Toure cut the deficit five minutes later with a scissor-kick volley, and Mancini sent on Balotelli as a substitute for the second half.
The Italian forward flicked a header into Aguero's path for the Argentine to shoot across goalkeeper Kenneth Vermeer and into the far corner of the goal.
Deep into stoppage time, Balotelli fell to the floor trying to turn and shoot as defender Ricardo van Rhijn tugged at his left arm.
Referee Rasmussen immediately blew the final whistle and was pursued by angry City players, who were joined by Mancini wagging a finger at the match officials.
In Madrid, Oezil scored with a free kick to ensure coach Jose Mourinho's team avoided a second straight defeat against German champion Dortmund, which won 2-1 at home two weeks ago.
Marco Reus gave Dortmund a 28th-minute lead with a fierce swerving shot to reward its attacking intent. The lead lasted six minutes before defender Pepe scored with a header.
Madrid goalkeeper Iker Casillas was beaten again in first-half stoppage time by teammate Alvaro Arbeloa's deflection from Mario Goetze's shot.
"It's not the result we would have wanted but they were a great team," said Pepe.
Ibrahimovic showed the huge gulf in class against a poor Zagreb side, creating scoring chances for defender Alex, midfielder Blaise Matuidi, winger Jeremy Menez and striker Guillaume Hoarau.
"He played for the team, as he always does," PSG coach Carlo Ancelotti said of Ibrahimovic. "He has extraordinary talent. He is a fantastic leader."
The Croatian champions have now lost 10 straight group-stage matches and failed to score in four matches this season.
PSG has nine points, one behind Porto, which has qualified for the knockout rounds with a stalemate in Ukraine. Host Dynamo Kyiv has four points.
Champions League debutant Malaga came to seven-time European champion Milan with a perfect record in its first three matches.
After goalkeeper Willy made excellent saves to deny Milan's Bojan Krkic and Urby Emanuelson, Eliseu put Malaga ahead against the run of play in the 40th minute.
Emanuelson's shot grazed the bar before halftime, and Milan finally scored the goal it deserved when Pato headed in Constant's cross to the far post.
Malaga has 10 points, five clear of Milan. Anderlecht has four points to move one above Zenit St. Petersburg after victory in Brussels.
Congo forward Dieumerci Mbokani, wearing a mask to protect a broken nose, struck in the 17th, taking a return pass from United States midfielder Sacha Kljestan to deftly lift the ball over Zenit 'keeper Viatsjeslav Malafeev.
Arsenal seemed set to avenge a 2-0 home defeat against Schalke last month, when Theo Walcott and Olivier Giroud scored within 26 minutes in Germany. Giroud's goal was a diving header from Lukas Podolski's perfect cross.
"At 2-0 you have not won the game and, with the physical quality of the German team, it isn't over," Arsenal manager Arsene Wenger said. "They have a lot of quality and they never give up, so overall I never felt that the game was over, even at 2-0."
Klaas-Jan Huntelaar scored in first-half stoppage time, after Walcott slipped, and Jefferson Farfan levelled in the 67th with a shot that took a deflection from defender Thomas Vermaelen.
Schalke heads the group with eight points, one clear of Arsenal. Olympiakos is a further point behind after late goals from Leonardo Greco and Costas Mitroglou sealed victory against winless Montpellier. Paulo Machado gave the Greeks a fourth-minute lead, which was cancelled out by Younes Belhanda's penalty in the 66th.
About 100 French fans clashed with riot police at Karaiskakis Stadium before the match.Suggest a correction