Samir Nasri and Pablo Zabaleta struck in the second half as Manchester City reached the Champions League knock-out 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.
City made a bright start to the second half as Nasri and Clichy both found space down the left but their crosses were cut out.
Normal service soon seemed to be resumed as Gervinho combined with Maicon to break clear but Fernando came to City's rescue and Hart then pushed away a long-range drive from Miralem Pjanic.
It came against the run of play when Nasri struck, moving inside from the left and hitting a ferocious shot from the edge of the area which crashed in off De Sanctis' near post.
City celebrated jubiliantly but the job was still far from done and Hart palmed over from Radja Nainggolan's powerful drive.
Francesco Totti shot over and frustration became evident in the Roma ranks as Ljajic slammed a water bottle into the ground after being substituted.
City breathed a sigh of relief as Kostas Manolas headed against the post from a free-kick and Martin Demichelis cleared off the line from Mattia Destro after Hart missed the resulting corner. But City then dug in and gained precious breathing space when Nasri held the ball up in the area and Zabaleta ran in to slam home a second goal in the dying moments.
A delighted Pellegrini said: "This is the way we have been playing for weeks. We are a solid team. All the team works together to get the ball and to support.
"I don't want to complain about the players we are missing. This team deserves a little more credit than the press always give us. We qualified and we can think about this in February. Now we must think about the Premier League. We have four more games in December."