Former City midfielders Jack Rodwell and Adam Johnson looked to have gained the visitors a point, only for the NYCFC loanee to pop up with a header in the closing stages.
The veteran former England midfielder sealed a controversial renewal to his stay at the Etihad Stadium late on New Year's Eve at the expense of New York City FC — the Major League Soccer club that is part-owned by City and where Lampard is set to conclude his decorated career.
On as a second-half substitute and with City looking set to spurn a two-goal lead for the second time in consecutive Premier League home games, Lampard guided a header from Gael Clichy's pinpoint 73rd-minute cross into the bottom corner.
It capped a frantic period of five goals in the space of just over 16 minutes — somewhat at odds with an uneventful first half.
Yaya Toure clattered home a brilliant long-range strike to give City a 57th-minute lead and when Stevan Jovetic slotted in an impudent flick, with Clichy the provider once more, Manuel Pellegrini's team appeared to have the necessary breathing space in a match during which Sunderland had rarely threatened.
But ex-City players Jack Rodwell and Adam Johnson — the latter from the penalty spot after Pablo Zabaleta had fouled Billy Jones — brought the score back to 2-2 as Burnley did Sunday, before Lampard had the final say.
Goalkeeper Willy Caballero replaced the rested Joe Hart in one of four alterations made by Pellegrini. Sebastian Larsson overcame an ankle problem to feature in a Sunderland midfield missing Lee Cattermole (groin) and Liam Bridcutt (concussion), meaning a start in the holding role for Rodwell.
City started with a conventional striker for the first time in four league matches and the Montenegro international Jovetic exchanged dinked passes with David Silva to lash wide left footed in the second minute.
Sunderland restricted the hosts during the opening stages before switching off from a 21st-minute short corner, when Silva steered wide at the end of penalty-box scramble.
Gus Poyet's men were almost rewarded for their obdurate defensive showing when Caballero made a fine save from Larsson's 40th-minute free kick.
The pattern set before the interval was soon re-established but it was from a familiar spell of patient but largely unthreatening City possession that Toure illuminated the contest, thrashing an unstoppable strike into the top corner from 25 yards.
Sunderland instantly sought to ask questions of its opponent at the other end, but it opened up space for a beautifully crafted passing move, which Jovetic stylishly finished in the 66th minute having played Clichy into space down the left flank.
But the France left back was soon found wanting as Rodwell towered over him to head in from Larsson's left-wing corner and Johnson leveled the score in the 71st minute after a slaloming run from substitute Ricky Alvarez brought panic and Zabaleta's error inside the City box.
It set the stage for Lampard to produce his seventh goal of the season and move fourth in the Premier League's all-time leading scorer list.
Sunderland goalkeeper Costel Pantilimon was to the fore in the closing stages against his former employers, touching a Jesus Navas strike against the base of the post and twice denying Lampard, whose goal helped to maintain the pressure on leader Chelsea.