ZAGREB, Croatia — Gabriel Jesus scored a 20-minute hat trick as Manchester City rallied for a 4-1 win at Dinamo Zagreb to scupper the Croatian team’s chances of advancing to the Champions League’s knockout stage on Wednesday.

With Shakhtar Donetsk losing 3-0 to Atalanta in a match being played at the same time, Dinamo would have secured a runner-up finish behind City with a win at Stadion Maksimir.

Dinamo even took the lead in the 10th minute against the already-qualified English champions when Dani Olmo, a player who has been linked with a possible move to City, met an inswinging cross from the right with a volley high into the net.

Jesus, again deputizing for the injured Sergio Aguero, led the fightback by City by heading in Riyad Mahrez’s cross for a 34th-minute equalizer. Dinamo’s players complained to the referee and to their City counterparts that the ball should have been kicked out of play in the buildup to the goal while teammate Petar Stojanovic was on the ground, claiming to be injured.

Five minutes into the second half, Jesus exchanged passes with Phil Foden before cutting inside in the area onto his right foot and curling a shot into the far corner.

The Brazil striker completed his haul in the 54th by stretching to volley in a left-wing cross from Benjamin Mendy, who was a constant threat at left back.

Jesus also scored a hat trick in last season’s Champions League, at home to Shakhtar , and has now scored five goals in three games since Aguero got injured.

“We are incredibly delighted with Gabby,” City manager Pep Guardiola said. "A striker needs goals and he scored three. Hopefully it can help his mood to be incredibly positive.

“Gabriel is an incredible fighter, how he helps us to defend and does absolutely everything, but a striker needs goals and that is important for him, for the team, for everything.”

Foden, City’s highly rated 19-year-old midfielder, wrapped up the win by finishing off a flowing team move with a close-range shot and also impressed as a replacement for the rested David Silva.

Foden is regarded as the heir apparent to Silva — who is leaving at the end of the season after 10 years at City — and already has three Champions League goals to his name as a teenager.

“He was so good,” Guardiola added. "I think he's a player, when he is close to the box, who is more dangerous than away from the box.

“He still has to learn a bit away from the box, for the tempo and speed, but when he played close to the box he can attack central defenders and he's incredibly dangerous. He played really well.”

City fielded a weakened team for the game having clinched a last-16 berth with a game to spare.

Still, Dinamo could not capitalize and dropped to fourth in the standings, missing out on a Europa League spot awarded to third-place finishers. Atalanta ended up finishing second to qualify with City.

Dinamo coach Nenad Bjelica was unhappy with City's equalizer but did not blame the visitors.

“I don't think the opponent did that on purpose,” he said.

“We are sad our European campaign is at an end but I am proud and happy for everything we showed in these six matches.”

___

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