Pep Guardiola's side were frustrated for long periods at the Etihad Stadium on Monday but found a way through thanks to captain Kompany's sensational strike.
Kasper Schmeichel was given no chance by Kompany's rocket in the 70th minute, with City moving back above Liverpool, a point ahead in top spot in the Premier League table.
City, now on a run of 13 consecutive league wins, will defend their Premier League title if they collect another three points at Brighton and Hove Albion on Sunday.
Kompany made a superb block to repel Ricardo Pereira as the hosts made an understandably nervy start.
Sergio Aguero scored the winner at Burnley with a goal that only marginally crossed the line but Schmeichel made a great save to claw the striker's header away after it hit the crossbar.
Chances were at a premium but Raheem Sterling should have opened the scoring in the 53rd minute, misjudging his jump for a header and sending the ball flying off target.
Ilkay Gundogan curled a 20-yard strike narrowly wide but Leicester were posing a threat on the break, James Maddison missing the target at the end of a counter-attack.
Schmeichel brilliantly denied Aguero again in the 69th minute but he was left helpless in the face of an unstoppable goal from the unlikeliest of sources.
Kompany drove into space from the back and thundered an unbelievable finish into Schmeichel's top-left corner from at least 25 yards out to spark wild celebrations.
Leicester's resistance broken, City were able to see out the match, although their former striker Kelechi Iheanacho missed a great late chance to level.
City are now one more win away from becoming the first team to defend the title for a decade.
What does it mean? Liverpool left helpless
Jurgen Klopp's Reds have put in a phenomenal effort this season, but they look like falling just short in the most competitive Premier League title race for some time.
They may still finish a superb campaign with 97 points but it is unlikely to be enough to dethrone City, who are making a strong case to be described as the best team of the Premier League era.
Kompany comes up trumps
City's skipper has lifted the Premier League trophy before but if Guardiola's men complete the job next weekend Kompany can reflect on a match-winning moment out of the very top drawer.
His team had looked uncomfortable under the pressure for large spells of the game but Kompany settled things with a truly unstoppable shot. It was City's 100th home goal of the season, but few have been more memorable.
Occasion too big for Foden
It was a bold call from Guardiola to start Phil Foden in midfield but his withdrawal early in the second half suggested the City boss felt he got his selection wrong. The teenager made a bright start and looked City's likeliest goalscorer in the opening half-hour, but he faded fast and lacked the authority and experience to stamp his undoubted talent on the contest.
Key Opta Facts
- City return to the top of the Premier League; the 32nd lead change this season, with 29 of those involving Liverpool or City.
- Vincent Kompany scored his 20th goal in all competitions for City, with his strike tonight versus Leicester his first from outside the box.
- Leicester have never won away from home on a Monday in the Premier League, drawing three and losing nine of their 12 such matches.
- City have scored in all of their home Premier League games in a single season for the third time (also in 11/12 & 12/13) - only Arsenal and Chelsea (four times each) have managed to do so on more occasions.
Brighton are the only obstacle still standing in City's way, with Chris Hughton's men welcoming the league leaders on Sunday. In a dead-rubber final fixture, Leicester host Chelsea.