Alvaro Negredo came off the bench to spare Manchester City's blushes as the Spanish striker's late goal inspired a 4-2 win over Viktoria Plzen in the Champions League on Wednesday.
Manuel Pellegrini's team were in danger of blowing their slender chance of finishing top of Group D after twice surrendering the lead against the Czech minnows at Eastlands.
Sergio Aguero had put City ahead with a first-half penalty, but Tomas Horava equalised before half-time.
Samir Nasri restored the hosts' advantage, only for Plzen to hit back again through Stanislav Tecl.
Substitute Negredo finally tipped the balance in City's favour with 12 minutes left and Edin Dzeko sealed the points in the final moments.
"I'm satisfied because we won but I think we didn't play well. We didn't play with the intensity we have showed here in the past," Pellegrini said.
"We can attack and score without giving so many chances in defence as we did today."
City's victory means they remain three points behind group leaders Bayern Munich and could finish top if they beat the holders at least 3-0 in the Allianz Arena on December 10.
With star midfielder Yaya Toure now suspended for the trip to Germany, that outcome is unlikely, so the more significant aspect of this match for City's long-term prospects will be the return of England goalkeeper Joe Hart from his spell in exile.
Hart had been dropped by Pellegrini after a series of error-prone performances hit a new low with an embarrassing blunder which sent City crashing to defeat at Chelsea.
The 26-year-old languished on the bench for the next five matches as Costel Pantilimon performed well in his place, with only a solitary appearance for England in their friendly defeat against Germany to sustain him.
On his return here, Hart made two fine saves to keep City in the game and couldn't be faulted for either of Plzen's goals.
With City already through to the knock-out stages, Pellegrini made seven changes, but still sent out a strong side featuring the likes of Aguero and Nasri, as well as the returning Hart.
Nasri almost opened the scoring when he exchanged passes with Fernandinho before slamming a fierce 25-yard shot against the crossbar.
Plzen were already out of the race for a last 16 place, but they caused City plenty of problems and should have taken the lead when Frantisek Rajtoral surged into the penalty area, only to miscue his cross-shot.
Moments later Michal Duris dragged a low effort wide from 12 yards as City's defence was carved open with alarming ease.
City finally took the lead in the 33rd minute when Rajtoral raised his arm to block a cross from Aguero.
Turkish referee Firat Aydinus pointed to the spot and Aguero stepped up to stroke home the penalty for his 16th goal of the season.
But Pellegrini, perhaps vexed by City's sloppy defending, still looked less than happy on the bench.
Pellegrini's fears were confirmed in the 43rd minute as City's back four crumbled, this time backing off en masse before Horava drove a superb strike from the edge of the area past Hart.
Aguero came off at half-time, but Toure was sent on in the second half and the Ivorian midfielder was instrumental when City regained the lead in the 65th minute.
Jesus Navas took Toure's pass and whipped over a pin-point cross which was volleyed home by Nasri.
Hart then made a brilliant one-handed save from Daniel Kolar's powerful strike.
He was beaten again in the 69th minute when more soft City defending allowed Kolar to feed Tecl for a clinical finish.
But, with City's hopes of top spot fading, Negredo came to the rescue with a tap-in from Navas's perfect cross in the 78th minute.
Even then City still rode their luck and it took a good save from Hart to deny Rajtoral and preserve the win.