The Reds scored three times in a rousing eight-minute spell in the second half to go 4-1 up, then clung on after City scored twice in the last six minutes.
Jurgen Klopp’s side – playing their first game since Philippe Coutinho’s £142m move to Barcelona – deserved their victory as they ended City’s hopes of going through the league season without losing, and extended their own unbeaten run to 18 games.
Alex-Oxlade Chamberlain’s low drive gave Liverpool an early lead, but City were level before half-time through Leroy Sane, who beat Loris Karius at his near post following Joe Gomez’s mistake.
The game turned decisively in two minutes either side of the hour mark, when poor defending by John Stones let in Roberto Firmino, and Sadio Mane – who had just hit the post – struck a stunning finish high past Ederson.
Ederson’s poor clearance gifted Mohamed Salah a fourth, and despite their late wobble, Liverpool closed out the win to go third in the table.
While the Reds’ top-four challenge goes from strength to strength, City can still reflect on a 15-point lead over Manchester United, who host Stoke on Monday.
Liverpool’s perfect post-Coutinho response
Liverpool fans may have wondered how Klopp and his side would respond after the sale of Coutinho. The first reaction was a thrilling one.
Coutinho has been central to Liverpool’s potent attacking style both as a scorer and creator of goals, but Klopp’s other game-changers stepped forward to suggest, on initial viewing at least, they can compensate for his departure.
Oxlade-Chamberlain now has a greater opportunity to make his mark, and he delivered after only nine minutes when he arrowed a low, unerring finish past Ederson’s outstretched right hand in front of the Kop.
Firmino harassed Stones into a decisive error before calmly restoring Liverpool’s lead at 2-1, while Mane’s explosive rising drive and Salah’s composure following Ederson’s poor clearance illustrated the weaponry at Klopp’s disposal.
This was all backed up by relentless pressing and harassing in midfield from players such as Emre Can, while Andrew Robertson subdued Raheem Sterling as he produced his best performance since his £8m summer move from Hull City.
Apart from Loris Karius’ poor attempt to save from Sane at his near post, compounding Joe Gomez’s mistake, this was an outstanding Liverpool performance until their late wobble.
As a taste of life post-Coutinho, it was highly satisfying for Klopp and Liverpool.
No panic for Guardiola and City
No invincibles; the unbeaten record over after 22 games. It all added up to the worst 90 minutes of the season for Guardiola and City.
Liverpool deserved their victory as City once again tasted defeat on a ground at which they have not won in 18 games stretching back to May 2003.
When the dust settles, however, City can look back at a truly magnificent campaign so far – and, more significantly, a lead that still looks unassailable.
City responded serenely to going behind early on, calmly playing their way back into contention until Sane put them back on level terms.
But Stones’ weak defending broke them and there was no comeback from those goals from Firmino and Mane either side of the hour mark.
It was a day when individual errors, such as those by Stones and Ederson, were punished and City simply could not summon up another of those late shows that have brought them so many points this season.
Even then, when not at their best, they gave Anfield a collective attack of nerves in those closing moments when the possibility of an escape suddenly presented itself.
It was a demonstration of the character in Guardiola’s side that they kept going – but, in the end, they finally had to taste defeat.
Miserable Anfield return for Sterling
Sterling has been regarded as the villain in these parts ever since he left Liverpool for City in a £49m deal in July 2015.
The ill-feeling towards the forward, who has been one of the Premier League’s standout players this season, was demonstrated by the raucous jeers that followed every intervention in this game.
There was no lack of effort from Sterling but little went right as he lost his battle with Liverpool left-back Robertson, who was outstanding.