Samir Nasri and Pablo Zabaleta struck in the second half as Manchester City reached the Champions League knockout stage with a brilliant 2-0 win at Roma.
French playmaker Nasri chose the perfect moment to score his first goal of the season, smashing in a shot via the woodwork on the hour at the Stadio Olimpico.
Until then a City side without three of their key players had been second best but Joe Hart was outstanding and they grew in confidence to claim a famous victory when Nasri set up Zabaleta after 86 minutes.
It completed a remarkable comeback in Group E, with progress having looked unlikely just a couple of weeks ago.
CSKA Moscow's defeat to Bayern Munich confirmed that City, who had just two points after four games, would join the Germans in the last 16 against the odds.
Despite City's heroics against Bayern to revive their campaign a fortnight ago, their task in the Italian capital always seemed a tough one.
It grew all the more daunting before kick-off as captain Vincent Kompany failed to prove his fitness to miss out along with the injured Sergio Aguero and suspended Yaya Toure.
City at least had playmaker David Silva back on the bench but they looked shaky from the outset as Roma - and principally former Arsenal forward Gervinho - ran at them at every opportunity.
Play was briefly held up in the first minute as City goalkeeper Hart removed an object from the pitch which had apparently been thrown from the stands.
But it soon started to look like Hart would have a busy night for more orthodox reasons as Gervinho got behind the defence and volleyed a cross which was scrambled clear.
Jose Holebas then went through on Hart but scuffed a shot that went through the keeper's legs but Zabaleta got back to clear.
Gervinho threatened again with good runs through the middle and down the left but City crowded him out and then saw Ivorian blaze over.
City had a chance when Gael Clichy found space to cross for lone striker Edin Dzeko but the Bosnian could not keep his header down.
City survived twice more Adem Ljajic shot over and Gervinho, after breaking from inside his own half, drove across goal and wide.
Nasri reached the byline to pull back for Dzeko but the striker scooped over and Jesus Navas had a strike disallowed for a foul in the build-up.
Former City defender Maicon and Gervinho both shot at Hart as Roma continued to look the better side but James Milner forced Morgan de Sanctis to block after breaking through.
Gervinho wanted a penalty after going down in the area but Serbian referee Milorad Mazic was not interested and booked Dzeko and Mapou Yanga-Mbiwa for some pushing and shoving in the aftermath.