City were the best team in the first 45 minutes even after losing Bayern Munich-linked Leroy Sane to injury, with Raheem Sterling giving them a deserved half-time lead with his first goal against Liverpool in his 11th outing versus his old club.
Jurgen Klopp's side improved after the break, though, and Joel Matip's leveller was just reward for their efforts, as City started to wilt in the warm conditions.
The excellent Claudio Bravo made sure the game went to penalties and proved the hero when he kept out Georginio Wijnaldum's effort, allowing Gabriel Jesus to seal victory.
The blow of losing Sane just 11 minutes in was quickly forgotten as City made the most of the resulting free-kick, Liverpool's offside trap all over the place as David Silva flicked Kevin De Bruyne's cut-back across goal and Sterling forced the ball beyond Alisson.
David Silva flicks it to Raheem Sterling, who scores his first goal against his former club! pic.twitter.com/gPWpMVVbEW— ESPN FC (@ESPNFC) August 4, 2019
City were in control but Liverpool could have levelled before the break had Mohamed Salah shown a touch of generosity, the forward clipping the outside of the post from a tight angle and then ballooning a second chance over the bar after a poor Oleksandr Zinchenko header, leaving Roberto Firmino angry not to receive a simple pass.
Guardiola then became the first Premier League manager to be booked on the touchline as he reacted furiously to a challenge from Joe Gomez on David Silva, the City boss suggesting the defender's boot had been dangerously high.
Sterling hit the base of the post - although any goal would have been ruled out for offside - as City started the second half strongly, with Guardiola and Klopp resisting the urge to make the most of the maximum six available substitutions at the break.
Liverpool suddenly threatened a leveller and were twice denied by the woodwork, Virgil van Dijk hitting the base of the crossbar with a half-volley and Salah firing against the foot of the right-hand post from the edge of the box.
Sterling then raced through on Alisson but dithered on the ball and the goalkeeper calmly took it back, and it proved a costly miss, with Matip nodding an equaliser past Bravo after Van Dijk picked him out in the six-yard box.
Joël Matip heads home Virgil van Dijk's cross to level it up at 1-1! pic.twitter.com/TMLqtsttRq— ESPN FC (@ESPNFC) August 4, 2019
Bravo prevented Naby Keita and Salah from snatching late winners, and the latter was denied from another glorious chance as Kyle Walker's acrobatic clearance on the goal line forced a shoot-out.
Bravo saved comfortably from Wijnaldum's spot-kick - the only one that was missed - before Jesus confidently swept the ball past Alisson and sparked City celebrations.
Annnnnnnd lift! 🙌 pic.twitter.com/Y7WBaofTiV— Manchester City (@ManCity) August 4, 2019
What does it mean? Little to split the Premier League's top two
City claimed the bragging rights and were certainly the better side early on, but this was another indicator that their league title crown will come under serious threat this season.
Liverpool have not had a particularly encouraging pre-season and there were similar problems laid bare here. The usually imperious defence looked uneasy, Roberto Firmino is short of sharpness and the place for Divock Origi is not wide on the left.
That said, they outplayed City after the break and really should have won in normal time. They look ready to push Guardiola's men all the way again in the top flight.
City's first choice in pre-season while Ederson had an extended break, Bravo was the only reason Liverpool did not win the game in normal time. He then saved Wijnaldum's penalty to secure the trophy.
Liverpool seemed to target Zinchenko and there were times when it was easy to see why. He was outmuscled by Salah too often, twice headed straight to red shirts within 20 yards of his own goal, and it was his foul that led to the equaliser.
City begin their Premier League title defence away to West Ham on Saturday. Liverpool kick off the top-flight season on Friday at home to Norwich City.