Match ends, Manchester City 4, Borussia Mönchengladbach 2.
Manchester City came back dramatically to beat Borussia Monchengladbach and pip Juventus to the top of Group D.
David Silva finished a fine team move but goals from Julian Korb and Raffael put the Germans ahead at the break.
Crucially, Juventus fell behind at Sevilla and Raheem Sterling poked in to give City hope of the win they needed.
Sterling then raced clear to curl Manuel Pellegrini's side ahead and substitute Wilfried Bony converted from six yards to cap an exhilarating night.
The draw for the last 16 will take place on Monday from 1100 GMT.
Slow start, frenetic finish
"If we play the way we did in the second half we can play against any team," Pellegrini said after watching City's fightback.
Bony's finish sparked wild scenes at the Etihad Stadium and when news of Juventus' defeat in southern Spain was confirmed, City fans could celebrate seeing their side top a Champions League group for the first time.
It looked a distant dream at the interval after a 45 minutes in which Pellegrini's side were again guilty of some charitable defending and played just 198 passes compared to 382 by the visitors.
But City began to dominate the ball and territory after the break, playing 361 second-half passes to build pressure which told and ultimately ensured the German side missed out on Europa League football.
On his 21st birthday, Sterling had created Silva's first goal since August with a deft backheel and he was on hand to level from Gael Clichy's cut-back.
Just 112 seconds later, he met Bony's pass to complete the remarkable turnaround. After 64 minutes City were behind with Juventus level, yet 11 minutes later, they led, as did Sevilla.
Manchester's mad 15 minutes
City fans will have bragging rights on Wednesday morning as Manchester United's collapse in the closing 15 minutes at Wolfsburg contrasted the fortunes of their local rivals.
In the most dramatic spell of this season's Champions League so far, United thought they were heading for the last-16 while City faced finishing as runners-up in their group.
Cue a Wolfsburg winner as Louis van Gaal's side floundered in Germany, while City's three goals in six minutes spun things in Manchester and the city will now have a Champions League and Europa League representative come February.
What is a good draw?
The reward for 12 points and top spot should, in theory, be an easier tie in the round of 16 when the draw is made on 14 December.
Sitting second in Group D after 78 minutes against Monchengladbach, City faced the grave reality of potentially meeting Real Madrid, Atletico Madrid, Bayern Munich or Barcelona - who have dumped City out in the round of 16 for the last two seasons.
City can meet the runners-up of other groups so Paris St-Germain and Benfica still lurk as possible opponents, but PSV Eindhoven look an easier option. There is still the possibility of a meeting with Valencia - now managed by ex-Manchester United defender Gary Neville.
It's not all thrilling
There are still questions for Pellegrini to answer.
His side have conceded 11 goals in six games, and the way in which Monchengladbach's second goal arrived - from a move which began near their own corner flag - underlined the soft centre City have developed.
Without captain Vincent Kompany this season they have conceded 19 goals in 10 Premier League and Champions League games. While Pellegrini insists their defensive quality does not hinge on Kompany's presence, it is surely key the Belgian is kept fit for the knockout stages.
But City will meet Tottenham, Leicester and Liverpool in the weeks surrounding their last-16 tie, so demands on the squad will be huge.
A major positive will be Bony's impact from the bench at the Etihad as the Ivorian proved that, despite only starting nine league games and three Champions League fixtures since his £28m arrival in January, he has the quality to influence proceedings at key moments in the absence of Sergio Aguero.
Man of the match - Raheem Sterling
Manchester City manager Manuel Pellegrini: "When we had the draw everyone said we had the death group. I said the group was not finished. We played not so well in the first half but did brilliant in the second half. We scored three and had more clear chances.
"The most important thing is to qualify. To avoid the important teams is perfect. I think for Manchester City it is very important to grow every year.
"Some day you are going to win Europe. This year? Could be next season? But I don't think this is the only goal for this group."
The stats you need to know
- Manchester City have conceded two or more goals in nine of their last 11 Champions League home games.
- They have failed to keep a clean sheet in each of their last 14 Champions League games at the Etihad Stadium.
- Raheem Sterling has been directly involved in five goals in his last three appearances in all competitions for Man City at the Etihad.
- 22ClichySubstituted forSagnaat 80'minutes
- 42Y Touré
- 18DelphSubstituted forBonyat 65'minutes
- 17De BruyneSubstituted forNavasat 65'minutes
- 8DahoudSubstituted forSchulzat 67'minutes
- 17WendtSubstituted forT Hazardat 84'minutes
- 19JohnsonSubstituted forDrmicat 72'minutes
- 10T Hazard
- Danny Makkelie
- Shots on Target
Second Half ends, Manchester City 4, Borussia Mönchengladbach 2.
Attempt missed. Wilfried Bony (Manchester City) right footed shot from the centre of the box is close, but misses to the right. Assisted by Jesús Navas.
Attempt saved. Raheem Sterling (Manchester City) right footed shot from the centre of the box is saved in the centre of the goal. Assisted by David Silva.
Attempt blocked. Lars Stindl (Borussia Mönchengladbach) right footed shot from outside the box is blocked.
Attempt saved. Thorgan Hazard (Borussia Mönchengladbach) right footed shot from outside the box is saved in the centre of the goal. Assisted by Raffael.
Attempt missed. Granit Xhaka (Borussia Mönchengladbach) left footed shot from outside the box is too high. Assisted by Julian Korb.
Attempt missed. Yaya Touré (Manchester City) right footed shot from outside the box is too high. Assisted by Jesús Navas.
Goal! Manchester City 4, Borussia Mönchengladbach 2. Wilfried Bony (Manchester City) left footed shot from the centre of the box to the centre of the goal.
Attempt missed. Wilfried Bony (Manchester City) right footed shot from the centre of the box is close, but misses to the right. Assisted by Aleksandar Kolarov with a cross.
Substitution, Borussia Mönchengladbach. Thorgan Hazard replaces Oscar Wendt.
Foul by Oscar Wendt (Borussia Mönchengladbach).
Wilfried Bony (Manchester City) wins a free kick in the attacking half.
Foul by Lars Stindl (Borussia Mönchengladbach).
Bacary Sagna (Manchester City) wins a free kick in the defensive half.
Goal! Manchester City 3, Borussia Mönchengladbach 2. Raheem Sterling (Manchester City) right footed shot from the centre of the box to the bottom right corner. Assisted by Wilfried Bony.
Substitution, Manchester City. Bacary Sagna replaces Gaël Clichy.
Goal! Manchester City 2, Borussia Mönchengladbach 2. Raheem Sterling (Manchester City) left footed shot from the centre of the box to the centre of the goal.
Attempt missed. Lars Stindl (Borussia Mönchengladbach) right footed shot from the left side of the box is high and wide to the right. Assisted by Marvin Schulz.
Attempt saved. Granit Xhaka (Borussia Mönchengladbach) left footed shot from outside the box is saved in the top right corner.