Pep Guardiola's treble-chasing side needed to win to retain control of their title destiny, and their 13th successive victory took them a point above Liverpool. City should successfully defend the title next Sunday at lowly Brighton. Liverpool hosts Wolverhampton.
It was anything but straightforward for City as Leicester, under the guidance of former Liverpool boss Brendan Rodgers, proved tough defensively and a threat on the break.
Yet City, knowing the importance of victory, gave it everything. They were again missing the midfield composure of Fernandinho but made their usual high-energy start.
Bernardo Silva and Raheem Sterling tore down the right and left flanks respectively and cut inside menacingly while Phil Foden, again trusted by Guardiola in another key fixture, was also lively.
Leicester was also relishing the contest and it was the visitors who created the first serious opening when Ricardo Pereira skipped into the area and had his shot blocked by Kompany. Marc Albrighton's follow-up effort was also charged down.
City threatened as Foden chested down and volleyed at Schmeichel, then Youri Tielemans forced a low save from Ederson.
Sterling raced behind the defense and flicked the ball onto Jonny Evans' arm but penalty appeals were half-hearted and dismissed by referee Mike Dean.
A sign of City tension came as David Silva was booked for a cynical challenge on Tielemans which prevented a breakaway from inside his own half.
But City then started to take control, and Sergio Aguero hit the bar with a thumping header. Schmeichel did brilliantly to claw the ball off the line as it bounced down.
City finished the half on top but there was another moment of alarm as Kompany was booked for bringing down James Maddison in full flow.
City sent on Leroy Sane and poured all its efforts into attack after the break. City appealed for another penalty as Sterling went down under a Hamza Choudhury challenge but nothing was given and the Foxes almost caught the hosts out as Maddison flashed an effort wide.
The tension increased and the anxiety was evident as Aguero was denied at point-blank range by Schmeichel after Evans miskicked.
Then Kompany produced his first league goal of the season. The celebrations from Kompany, Guardiola and almost everyone connected with the home side were exuberant and emotional but the game still had to be closed out.
Hearts will have been in mouths when former City striker Kelechi Iheanacho got clear but he missed the target, and City held on.
The keys scenarios:
Manchester City at Brighton (17th)
A win clinches the title, a draw along with a Liverpool defeat or draw also is enough.
Liverpool at Wolves (seventh)Need to win and City to draw or lose to claim title.