McNair, signed from Manchester United, could not avoid heading into his own net after Jesus Navas fizzed a dangerous ball across the face of the goal.
After Sergio Aguero’s early penalty for Man City, Jermain Defoe had put David Moyes on course for a draw on his first Premier League match as Sunderland manager, when he slotted under Willy Caballero, in the City team ahead of Joe Hart, with 20 minutes left. But City had the last say.
Aguero scored the first league goal of Guardiola’s reign when he slotted in a fourth-minute penalty after Raheem Sterling was tripped by Patrick van Aanholt.
Summer signing Nolito flashed a shot wide in a first-half of few opportunities, despite the hosts dominating possession with fellow new recruit John Stones and central defensive partner Aleksandar Kolarov pressing high up the pitch.
Caballero made a fine reflex save from a close-range Defoe strike near the end of the first half.
After the break, Aguero dragged a shot wide and Kevin De Bruyne’s free-kick was palmed out by Vito Mannone before the equaliser.
Defoe struck as he latched on to a slide rule pass from Jack Rodwell and slotted the ball under the body of Cabellero.
Bacary Sagna then headed wide before McNair, just minutes after coming on as a substitute, inadvertently scored Man City’s winner.