Leicester became the first visiting side to keep out Man City in the opening hour of a league match this season, though Kompany fired home the winning goal 20 minutes from time to lift the Citizens above Liverpool at the top of the table.
After cagey matches against Manchester United and Burnley over the past couple of weeks, this proved to be another tense and at times frustrating night for the defending champions, but they got the job done.
Man City will become the first side in a decade to win the Premier League title in back-to-back seasons if they beat Brighton & Hove Albion on the final day of the campaign, as Liverpool - who host Wolverhampton Wanderers the same day - are a point worse off.
Schmeichel had just one other stop to make in the opening 45 minutes, getting down to his left to keep out Bernardo's shot right at the end of the half.
In-between those two weak attempts, Sergio Aguero got on the end of a corner at the near post and sent his header against the crossbar - the ball coming back down but, unlike at Turf Moor last weekend, it did not cross the line.
Leicester, needing victory to keep alive their slim top-seven hopes, had a couple of promising moments as Youri Tielemans sent a shot down the middle for Ederson to save and Ricardo Pereira was denied by Kompany's block.
Only twice this season have Guardiola's men failed to score in the first half of a home league match, and they went on to collect all three points against Watford and West Ham United.
This was proving to be a far trickier test, though, and after wayward shots from Raheem Sterling and Bernardo Silva, Guardiola brought on Sane for Foden and set out his side in an attacking formation.
A few minutes after Sterling had a penalty shout turned down after being sandwiched by two players in the box, Harry Maguire carried the ball forward for Leicester and teed up James Maddison, who sent a curled shot inches wide of the target.
With 20 minutes to go, and Leicester looking threatening on the counter, up stepped Kompany with a 25-yard bullet into the top corner of the net - his 20th goal in all competitions for the club, and one of the most memorable of the lot.
Leicester could easily have spoiled the early title celebrations, though, as Marc Albrighton had a shot kept out and ex-Man City striker Kelechi Iheanacho sent a first-time shot wide of the target from a glorious position shortly after being introduced from the bench.
MANCHESTER CITY (4-3-3): Ederson; Walker, Kompany, Laporte, Zinchenko; D.Silva (Stones 91'), Gundogan, Foden (Sane 56'); Bernardo, Aguero (Jesus 87'), Sterling
LEICESTER CITY (4-5-1): Schmeichel; Pereira, Evans, Maguire, Chilwell; Albrighton (Gray 85'), Tielemans (Barnes 75'), Ndidi, Choudhury, Maddison (Iheanacho 80'); Vardy