Liverpool almost took the lead on 18 minutes at the Etihad Stadium.
Sadio Mane's shot came back off the inside of the post before John Stones's attempted clearance hit Ederson and was 1.12cm from crossing the goalline before the City defender hooked clear.
City struck first five minutes before half-time. Sergio Aguero stole ahead of Dejan Lovren and beat Alisson with a fierce shot from a narrow angle for his seventh goal in as many home matches against Liverpool.
On 64 minutes Liverpool were level. Trent Alexander-Arnold's crossfield pass was played back across goal by Andy Robertson for Roberto Firmino to head in.
Sane restored City's advantage in the 72nd minute, firing in via the far post after racing on to Raheem Sterling's pass.
Victory means the defending champions are now second, four points behind Liverpool, who are top with 54.
Man City: 14 Jan v Wolves (H)
Liverpool: 12 Jan v Brighton (A)