While former champions Liverpool and Porto eased to the knockout stage of the Champions League, record 13-time champion Real Madrid faces an embarrassing group-stage exit after losing 2-0 at Shakhtar Donetsk in Tuesday’s games.

Zinedine Zidane’s side would have advanced with a win, but it has defended poorly all season and was undone by counterattack goals in the second half. Instead of progressing, Madrid dropped to third place in Group B behind the Ukrainian side and Borussia Mönchengladbach.

Six-time champion Liverpool overcame injury problems to beat four-time winner Ajax 1-0 at Anfield, thanks to a second-half goal from midfielder Curtis Jones.

Moenchengladbach's Marcus Thuram, right, fights for the ball with Inter Milan's Matteo Darmian during the Champions League, Group B, soccer match between Borussia Moenchengladbach and Inter Milan at the Borussia Park in Moenchengladbach, Germany, Tuesday, Dec. 1, 2020. (AP PhotoMartin Meissner)

Moenchengladbach's Marcus Thuram, right, fights for the ball with Inter Milan's Matteo Darmian during the Champions League, Group B, soccer match between Borussia Moenchengladbach and Inter Milan at the Borussia Park in Moenchengladbach, Germany, Tuesday, Dec. 1, 2020. (AP PhotoMartin Meissner)

Two-time winner Porto held already-qualified Manchester City to a 0-0 draw at home, although City ensured the top spot.

No drama in those two groups, but plenty in Madrid’s as Gladbach missed the chance to advance after losing 3-2 at home to three-time champion Inter Milan, which had to win.

Atlético Madrid did not do enough, drawing 1-1 at home to Bayern Munich even though the defending champion fielded a weakened side having already qualified.

Liverpool's Curtis Jones celebrates scoring his side's first goal during the Champions League group D soccer match between Liverpool and Ajax at Anfield stadium in Liverpool, England, Tuesday, Dec. 1, 2020. (Paul EllisPool via AP)

Liverpool's Curtis Jones celebrates scoring his side's first goal during the Champions League group D soccer match between Liverpool and Ajax at Anfield stadium in Liverpool, England, Tuesday, Dec. 1, 2020. (Paul EllisPool via AP)

ALÉTICO CLOSE

Munich rested prolific striker Robert Lewandowski and standout goalkeeper Manuel Neuer but still did well enough to stop the Spanish side winning.

Atlético’s in-form striker Joao Felix faced less competition without Neuer thwarting him, and he swept in Marcos Llorente’s cross from the byline midway through the first half.

Moenchengladbach's Alassane Plea, left, celebrates after scoring his side's opening goal during the Champions League, Group B, soccer match between Borussia Moenchengladbach and Inter Milan at the Borussia Park in Moenchengladbach, Germany, Tuesday, Dec. 1, 2020. (AP PhotoMartin Meissner)

Moenchengladbach's Alassane Plea, left, celebrates after scoring his side's opening goal during the Champions League, Group B, soccer match between Borussia Moenchengladbach and Inter Milan at the Borussia Park in Moenchengladbach, Germany, Tuesday, Dec. 1, 2020. (AP PhotoMartin Meissner)

But veteran forward Thomas Müller equalized from the penalty spot in the 86th.

In Group A’s other game, striker Mergim Berisha netted twice as Salzburg won 3-1 at Lokomotiv Moscow to move into third place and prevent the Russian side reaching the round of 16.

Salzburg will upset the odds and qualify if it beats Atlético at home next week, but Diego Simeone’s Atlético needs only a draw.

MADRID DEFENDS POORLY

Madrid has advanced to the knockout stage in all 24 of its previous group-stage campaigns but things are looking tense. Madrid has conceded nine goals in five games for its worst-ever defensive record at this stage, losing twice to a Shakhtar side which leaked 10 goals in two defeats to Gladbach.

Brazilian forward Dentinho profited from a mix-up between Ferland Mendy and Raphael Varane to net in the 57th minute following a counterattack. Zidane’s players failed to take heed and the second stemmed from another counter as substitute Manor Solomon finished confidently.

Over in Germany, Inter had to win to have a chance at reaching the next round and the ever-reliable Romelu Lukaku saw to that with two goals.

Midfielder Matteo Darmian netted early on for Inter and French striker Alassane Pléa nodded the home side level, only for Lukaku to net twice after the break before Pléa replied again.

Remarkably, all four sides in Group B can still qualify.

Gladbach needs only draw at Madrid, while last-place Inter advances with a home win over Shakhtar next week unless Gladbach and Madrid draw.

BATTLE FOR THIRD

Porto needed just one point and was hardly troubled against group winner City, which has a strong record of 10 goals for and only one against.

Not so for Marseille, although at least the French side avoided the humiliation of a 14th straight competition defeat as Dimitri Payet netted two video-review penalties in a 2-1 home win against Olympiakos.

The win leaves both sides on three points as they contest third place and a Europa League spot.

But Marseille needs to better the result of Olympiakos next week, because Olympiakos beat Marseille 1-0 at home and has a better head-to-head record with an away goal.

Marseille has a tougher-looking game at City as Olympiakos hosts Porto.

THE KIDS ARE ALL RIGHT

A first European goal from Jones was heart-warming for coach Jürgen Klopp as he bemoans considerable injury problems and a congested fixture list.

Klopp can take comfort from the quality of the young players in Liverpool’s ranks as Jones scored off a cross from fellow 19-year-old Neco Williams. At the other end, there was a confident debut from goalkeeper Caoimhin Kelleher keeping out Ajax’s attacks in the absence of injured No. 1 Alisson Becker.

In Group D’s other game, newcomer FC Midtjylland stunned Atalanta by drawing 1-1 in Bergamo for its first point.

Alexander Scholz put the Danish side ahead in the 13th before fellow center back Cristian Romero grabbed a 79th-minute equalizer for last season’s quarterfinalist.

It proved a crucial goal.

For Ajax is one point behind Atalanta, and must beat the Italian side at home in next week’s finale.

More AP soccer: https://apnews.com/Soccer and https://twitter.com/AP_Sports