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.

Manchester City's Gabriel Jesus, left, celebrates with Manchester City's Phil Foden after scoring his side's second goal during the Champions League group C soccer match between Dinamo Zagreb and Manchester City at Maksimir Stadium in Zagreb, Croatia, Wednesday, Dec. 11, 2019. (AP PhotoDarko Bandic)

Manchester City's Gabriel Jesus, left, celebrates with Manchester City's Phil Foden after scoring his side's second goal during the Champions League group C soccer match between Dinamo Zagreb and Manchester City at Maksimir Stadium in Zagreb, Croatia, Wednesday, Dec. 11, 2019. (AP PhotoDarko Bandic)

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 build-up 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.

Manchester City's Phil Foden celebrates with teammates after scoring his side's fourth goal during the Champions League group C soccer match between Dinamo Zagreb and Manchester City at Maksimir Stadium in Zagreb, Croatia, Wednesday, Dec. 11, 2019. (AP PhotoDarko Bandic)

Manchester City's Phil Foden celebrates with teammates after scoring his side's fourth goal during the Champions League group C soccer match between Dinamo Zagreb and Manchester City at Maksimir Stadium in Zagreb, Croatia, Wednesday, Dec. 11, 2019. (AP PhotoDarko Bandic)

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.

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.

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