Two goals in the first half seemed to have lit the celebration candles but Paul Pogba dragged United back with two goals in the space of two minutes with Chris Smalling getting the winner with 21 minutes on the clock.
Kompany wrestled off Chris Smalling to score the first with a powerful header in the 25th minute and Ilkay Gundogan toe-poked past David de Gea for the second on 31 minutes.
There was a raft of goal scoring chances afterward from Sterling and Gundogan, which they wasted. They were made to rue those chances in the second half as United came storming back.
City could have been five goals up in the first half with misses galore from Raheem Sterling and another straight header from Gundogan that was straight at David de Gea.
United looked a different team in the second half as Pogba started to roam and Alexis Sanchez stayed in a more central position. United scored the first after consistent pressing as Pogba lifted a chest pass from Ander Herrera over Ederson.
The equaliser soon followed as Pogba got on the end of a lofted pass from Sanchez. The Etihad grew silent but United were not finished as Smalling atoned for City’s first goal when he hot on the end of a free kick from Sanchez.
De Gea still had more to do as he saved a sure goal with five minutes left on the clock from substitute Sergio Aguero.
It is the first time that Pep Guardiola’s team has conceded three goals in consecutive matches and the first loss at the Etihad Stadium since March 12, 2016 – 490 days. City will now have to win the title next Saturday against Tottenham at Wembley.