It was a night that will go down in history in more ways than one as Sergio Agüero wrote his name into the record books by registering his 178th goal for Manchester City to move one ahead of Eric Brook and become the club’s all-time leading scorer. The goal proved to be one of the defining moments in a thrilling game that ended with Pep Guardiola’s side becoming the first English club to win in Naples, securing their place in the knockout stage of the Champions League and showing once again why they are arguably the outstanding team in Europe on current form.

They are unbeaten in 16 games in all competitions this season, winning 14 of them, and have racked up a remarkable 49 goals along the way, with their latest display of swashbuckling football blowing away Napoli and leaving the Serie A leaders’ hopes of joining City in the last 16 hanging by a thread.

It was an extraordinary night in so many respects as the game swung one way and then the other, but ultimately it was an occasion that belonged to Agüero, who marked his 264th appearance for City with the goal that broke Brook’s 78‑year‑old record, putting Guardiola’s team 3-2 ahead and inflicting a blow from which Napoli were unable to recover. It was a brilliant breakaway goal from a team who are irresistible going forward, and for possibly the first time on the night the raucous home support inside the Stadio San Paolo sensed the game was up for Napoli.

Raheem Sterling, thrashing home his 10th goal of the season in injury time, confirmed that was the case as City became the first team to win in Napoli since Real Madrid eliminated them from the Champions League in March. Madrid went on to win the competition three months later and on the evidence of what we have seen so far this season, it would be no surprise if City end up doing the same.

This was a major test for City, especially when Napoli took the lead through Lorenzo Insigne after dominating the opening 20 minutes, yet Guardiola’s team came through it superbly, much to the Spaniard’s delight. Headers from Nicolás Otamendi and John Stones turned the match on its head and although Jorginho hauled Napoli level from the penalty spot, City possess that rare ability to go through the gears and take the game away from opponents at the crucial time.

Leroy Sané did just that when he ran clear and there was a sense of inevitability about what would follow when the loose ball broke to Agüero on the edge of the area. At the home of the club where Diego Maradona remains such an iconic figure, the Argentinian expertly placed his shot wide of Pepe Reina and wheeled away to celebrate his landmark goal.

“When one guy achieves what he has achieved, there’s big congratulations,” Guardiola said. “He’s a legend for the club, for the history, and everybody has to be so proud of that.”

Yet for Guardiola the most satisfying part of the match was the way in which his team recovered from Napoli’s blistering opening, which culminated in Insigne scoring a delightful goal after exchanging passes with Dries Mertens to carve open City. “They destroyed us in the first 20 minutes, especially on the left side,” Guardiola said. “In the first 20 minutes I was suffering but at the same time I was like a spectator, thinking: ‘Wow, how good are they playing.’”

The complexion of the game changed around the half-hour mark when Napoli lost Faouzi Ghoulam, their rampaging left-back, to injury and City started to come to life. Kevin De Bruyne’s short corner picked out Ilkay Gündogan, who delivered a diagonal cross towards the far post where Otamendi towered above Elseid Hysaj to head home.

With City now growing in confidence, Stones headed against the crossbar at the end of the first half and again shortly after the restart, with his second effort, from Sane’s corner, bouncing off the underside of the bar and over the line.

Napoli, however, were never going to surrender. Insigne cut inside and thumped the crossbar with a 25-yard shot and then came the penalty that Jorginho coolly converted after Sané had brought down Raúl Albiol with a clumsy challenge.

The game was wide open and José Callejón would have put Napoli ahead but for a fine save from Ederson. Napoli were desperate for a winner but that desire to push forward left the space for City to exploit on the counterattack as Agüero restored their lead. Sterling, set up by De Bruyne, finished the job in the closing seconds. “Whenever it is going well it is easy,” Guardiola said. “The point is how in the bad moments the team can react and we did that well, that’s why I am so pleased.”