The Germans had looked like being frustrated in a pulstaing Group E clash at the Allianz Arena as Hart produced a series of outstanding saves to deny the likes of Thomas Muller, Mario Gotze, David Alaba and Robert Lewandowski.
City did threaten themselves, and David Silva thought he should have had a penalty late on, but Bayern were the dominant side and Boateng struck from distance in the last minute.
Defeat was harsh on Hart, who just moments before Boateng found the net had made another fine one-handed save to deny his former team-mate.
City had also ridden their luck at times as Bayern, despite missing Franck Ribery, Bastian Schweinsteiger, Thiago Alcantara and Javi Martinez, lived up to their formidable reputation.
Yet City's approach was positive and bodes well for the rest of their campaign in a difficult group.
Edin Dzeko led the attack as Sergio Aguero started on the bench.
Bayern also had Arjen Robben among their substitutes but he hardly seemed to be missed as his side did all the early pressing.
City had a let-off in the first minute as Gotze slipped in Muller.
The World Cup-winning forward took the ball in his stride and skipped round Hart, creditably staying on his feet despite a possible touch from the goalkeeper, but could only find the side-netting.
City were pushed back and it was some time before they were able to enjoy some possession.
When they did they showed they wanted to give as good as they got.
Silva always looked composed on the ball and his clever reverse pass set up a good chance for the threatening Dzeko, whose first-time shot tested Manuel Neuer at his near post.
At the other end Lewandowski, on whom pressure is beginning to mount as he seeks his first home goal since joining Bayern in the summer, was denied by a well-timed Bacary Sagna challenge.
Hart then began to remind everyone of the talented goalkeeper he still is, saving twice in quick succession from a powerful Muller header and a well-struck Gotze drive.
Boateng fired over and Alaba shot wide as Bayern maintained their tempo.
Yet City, and particularly Dzeko, were still a threat and the Bosnian curled a good effort narrowly wide.
Boateng also made a vital interception as Jesus Navas got behind the Bayern defence and looked to pick out the lone frontman.
Hart came to City's rescue again when Alaba tested him with another firm shot and although Lewandowski did get round the keeper, he could only find the side-netting.
Bayern pushed again early in the second half with captain Philipp Lahm firing wide from distance.
Muller did well to keep another attack alive and find Gotze, but he could not get sufficient power on a shot to beat Hart.
Hart seemed to have been caught out when he missed a cross but he instantly redeemed himself by tipping over Mehdi Benatia's cross back into the danger area.
Bayern wanted a penalty when the resulting corner dipped over Hart and struck Fernandinho at the back post, but Spanish referee Alberto Mallenco saw no handball.
City chances were becoming a rarity but Silva had a good one when he got ahead of his marker to meet a Navas cross but he could only divert his header wide.
Hart had a moment of alarm when he fumbled a long-range effort from Rafinha and the ball dropped to the feet of Muller but the striker was flagged offside.
City turned to the fresh legs of Aguero with 16 minutes remaining, sending on the Argentinian for Dzeko, while Robben entered the fray for Bayern two minutes later.
Robben was soon in the thick of the action, going down in familiar style in the area after a challenge from Fernandinho, but nothing was given.
Silva was also denied a penalty after a challenge by Benatia but Bayern finished strongly with Boateng stinging Hart's palm before beating moments later when the ball fell to him from the resulting corner - via a slight deflection off Gotze's back.