Scott Sinclair's first-half strike for the visitors was cancelled out by Hearts trialist Osman Sow after the break but Aleksandar Kolarov scored a penalty to secure victory.
It was billed as a night of celebration with the pre-season game being used to mark the centenary of the Tynecastle main stand. The home fans, though, were just delighted to see their team on the pitch following the club's official exit from administration after a year-long battle for survival.
Even without their World Cup players, the visitors had a collection of players in their squad for the natives to get excited about: Samir Nasri, Javier Garcia and Alvaro Negredo among others.
Manuel Pellegrini's side soon went ahead. Negredo found Sinclair in the box and the midfielder kept his calm amid shouts for offside to cooly roll the ball pass Neil Alexander.
With the exception of the goalscorer, City named a completely different line-up after the break. And Hearts, who signed the former Rangers goalkeeper Scott Gallacher yesterday, levelled after 56 minutes when Sow, in his second game for the club after being released by Crystal Palace, raced on to Dale Carrick's pass before calmly lifting the ball past Willy Caballero.
City were awarded a penalty with 10 minutes to go when Callum Paterson brought down Emyr Huws after taking a bad first touch. Kolarov - roundly booed after criticising Paterson for a challenge on Caballero - silenced the home crowd with a clinical finish.