The visiting Czechs twice equalised with Manuel Pellegrini's side before two strikers saw the hosts over the line, Tomas Horava and Stanislav Tecl having put hearts in mouthsManchester City kept their faint hopes of winning their Champions League group alive by beating Viktoria Plzen 4-2 at the Etihad Stadium.
Alvaro Negredo and Edin Dzeko struck in the last 12 minutes from time as the Premier League outfit made hard work of seeing off the Czech champions on Wednesday and they could still win the group with a decisive victory at Bayern Munich in December.
In-form striker Sergio Aguero put Manuel Pellegrini's side in front from the penalty spot with his 15th goal in his last 12 games after Frantisek Rajtoral was harshly judged to have handled in the area. However, the Czechs were level at the break courtesy of an impressive strike from Tomas Horava.
Samir Nasri put City back in front but Plzen levelled for a second time in a frantic encounter when Stanislav Tecl fired home.
Negredo gave his side the lead for a third time when he finished from close range and Dzeko sealed the points at the death as the hosts took their tally to 22 goals in their last four home games.
Joe Hart made his first City start for a month as Pellegrini made seven changes to the side which hammered Tottenham 6-0 on Sunday while Roman Hubnik came in at left-back for Plzen to replace David Limbersky, who was out with a stomach problem.
Nasri looked in the mood early on, rattling the crossbar with a vicious right-footed strike after 13 minutes.
Plzen were not content to sit and soak up pressure, though, and could have taken a surprise lead after 26 minutes when Rajtoral raced into the box and flashed the ball across the face of goal.
The defender's disappointment at spurning that opportunity was compounded 12 minutes before the break, when he was harshly deemed to have handled in the area and Aguero sent Matus Kozacik the wrong way from the spot.
Plzen gave as good they got in the first half and were deservedly level two minutes before the interval when Horava rounded off a slick move with a right-footed strike into the far corner that gave Hart no chance.
Jesus Navas replaced Aguero at the break and they were almost back in front when Fernandinho's header was tipped over by Kozacik but the goalkeeper was beaten after 65 minutes when Yaya Toure made an immediate impact after coming on when he laid the ball off for Navas, whose cross was volleyed home left-footed by an unmarked Nasri.
Hart produced an outstanding reflex save to tip over Daniel Kolar's long-range drive a minute later but Tecl capitalised on some hesitant City defending to equalise with a measured right-foot finish from inside the area with 20 minutes to go.
There was still time for a final twist and Negredo provided it as he converted a Navas cross before Dzeko had the final say by heading home an inviting James Milner cross at the back post to seal the points.