City started the final round of group play in last place in Group E but finished second by beating Roma 2-0 away, with second-half goals by Samir Nasri and Pablo Zabaleta lifting the English champions above their Italian opponents and CSKA Moscow. CSKA lost 3-0 at Bayern Munich.
Schalke ensured a clean sweep of four German representatives in the last 16 for the second straight season after its 1-0 win at Maribor sealed the runner-up spot in Group H. Sporting Lisbon needed a draw at Chelsea to finish second but lost 3-1.
Barcelona came from behind to beat Paris Saint-Germain 3-1 and leapfrog the French team to the top of Group F, with Messi leading the Spanish side's recovery before goals by the remainder of its all-star attacking trio — Neymar and Luis Suarez.
Ajax and Athletic Bilbao won to clinch Europa League berths for finishing third in their groups, joining Sporting and Roma in the knockout stage of the continent's secondary competition that starts in February.
The draw for the last 16 of the Champions League is made on Monday, with teams from Germany (4), Spain (3) and England (3) making up 10 of the qualifiers.
City, along with PSG and Juventus, arguably will be the sides most group winners want to avoid after advancing for the second straight season thanks to wins over Bayern and Roma in its last two games.
Without four of its top players in the injured Sergio Aguero and Vincent Kompany, the suspended Yaya Toure and playmaker David Silva, who was on the bench, the Premier League champions qualified the hard way in the Italian capital.
Nasri smashed a rising shot in off the post from outside the area in the 60th minute before setting up right back Zabaleta for the second goal in the 88th minute. City also required a string of great saves from goalkeeper Joe Hart either side of halftime, while Martin Demichelis cleared a shot off the line when the score was 1-0.
"We had a bit of a slow start (in the group) but you don't win the Premier League easily," Hart said. "We've got resolve, we've got character and we've got great players. Add that all together and you have a chance."
City needed to better the result of CSKA and Bayern ensured that was the case as goals by Thomas Mueller — from the penalty spot — Sebastian Rode and Mario Goetze saw the German champions finish on 15 points.
For his side to advance, Schalke coach Roberto Di Matteo required a win in Slovenia and for Chelsea, the team he led to the Champions League title in 2012, to beat Sporting at Stamford Bridge.
Schalke did its part thanks to Max Meyer's 62nd-minute winner following a goalkeeper error, and a makeshift Chelsea side that was already assured of top spot in the group was too strong for Sporting.
Cesc Fabregas and Andre Schuerrle scored in the opening 16 minutes for Chelsea, Jonathan Silva replied before John Obi Mikel clinched victory.
Top spot — and a likely easier last-16 match — was up for grabs at Camp Nou and Zlatan Ibrahimovic put PSG ahead against his old club Barcelona in the 15th.
Messi equalized four minutes later, Neymar gave Barca the lead with a spectacular long-range shot in the 42nd and Suarez tapped in the third in the 77th. Barcelona has won its group for eight consecutive years, while PSG went down to a first defeat in its 23rd game of the season.
Belarussian club BATE Borisov bowed out of the Champions League with a 2-0 loss to Bilbao in Group H and a record number of goals conceded in group play — 24. Porto, which had already won the group, drew 1-1 at home to Shakhtar Donetsk.
Atletico Madrid, Juventus, Real Madrid, Basel, Monaco, Bayer Leverkusen, Borussia Dortmund and Arsenal qualified from the groups that finished playing on Tuesday.Suggest a correction