Guardiola, a European Cup winner with Barca as a player in 1992 before twice guiding the Catalan giants to the Champions League title in 2009 and 2011, will also come up against Borussia Monchengladbach and Celtic in Group C.
City lost to Barcelona in the last 16 of the competition in 2013-14 and 2014-15, while the Premier League side defeated Gladbach twice in last year's group stage.
"It's not a nightmare draw at all because we are in a wonderful competition and we are really happy to be here, but in Barcelona, Borussia Monchengladbach and Celtic we know it won't be easy," said City's director of football Txiki Begiristain.
"We reached the semi-final last season and we want to go far in the Champions League again. It is a very difficult competition to win - for everybody - and you need luck along the way, but we are ready and always trying to improve."
City captain Vincent Kompany tweeted: "Usual type of draw for us. Better like this. Bring it on."
Ronaldo crowned best player in Europe
Defending champions Real Madrid, who won a record 11th European Cup last season, were paired with Borussia Dortmund in Group F alongside Portugal's Sporting and Legia Warsaw of Poland.
Dortmund edged Real 4-3 on aggregate in a thrilling semi-final three years ago, but the Spaniards avenged that defeat, winning 3-2 over the two legs, the following season on their way to the 2014 title.
"We now have an appealing group. It's difficult but equally attractive. Matches against Real are becoming classics for Dortmund. We are looking forward to meeting the holders," said Dortmund coach Thomas Tuchel.
Five-time winners Bayern Munich will play last year's beaten finalists Atletico Madrid in Group D, which also features PSV Eindhoven and Russian first timers Rostov.
"It will be a very difficult group, we have to be careful," said Bayern coach Carlo Ancelotti, in his first season in Germany after replacing Guardiola.
No guarantees for winning title: Bayern chairman
"Atletico Madrid already threw FC Bayern out of the competition last season. Rostov surprised me with a big win over Ajax and Eindhoven only lost narrowly to Atletico last season on penalties. This group won't be easy."
Paris Saint-Germain and Arsenal are the two clear favourites to progress from Group A ahead of Basel and Bulgarian outfit Ludogorets, with Arsene Wenger's side preparing for a 19th successive appearance in the competition.
Premier League champions Leicester City were handed a favourable draw in Group G which includes Porto, Club Brugge and FC Copenhagen, but Foxes boss Claudio Ranieri was quick to downplay expectations.
"Once again I say we are underdogs," said Ranieri. "For this reason we must fight for everything. I want to see my players fight against the best in Europe.
"Last season was wonderful but I want more. Now we are in the Champions League and we have another wonderful opportunity to show our quality."
City to lose Hart despite qualifying for Champions League
Juventus will take on three-time reigning Europa League champions Sevilla as well as Lyon and Dinamo Zagreb in Group H.
Tottenham Hotspur, who return to Europe's elite for the first time since reaching the 2010-11 quarter-finals, will come up against Russian champions CSKA Moscow, Bayern Leverkusen and Monaco in Group E.
Twice former champions Benfica, Napoli, Dynamo Kiev and Besiktas are in Group B.
The first matches will be played on September 13 and 14, while this season's final is to be held at the Principality Stadium in Cardiff on June 3.
Groups
Group A: Paris Saint-Germain (FRA), Arsenal (ENG), Basel (SUI), Ludogorets Razgrad (BUL)
Group B: Benfica (POR), Napoli (ITA), Dynamo Kiev (UKR), Besiktas (TUR)
Group C: Barcelona (ESP), Manchester City (ENG), Borussia Monchengladbach (GER), Celtic (SCO)
Group D: Bayern Munich (GER), Atletico Madrid (ESP), PSV Eindhoven (NED), Rostov (RUS)
Group E: CSKA Moscow (RUS), Bayer 04 Leverkusen (GER), Tottenham Hotspur (ENG), Monaco (FRA)
Group F: Real Madrid (ESP), Borussia Dortmund (GER), Sporting (POR), Legia Warsaw (POL)
Group G: Leicester City (ENG), FC Porto (POR), Club Brugge (BEL), FC Copenhagen (DEN)
Group H: Juventus (ITA), Sevilla (ESP), Lyon (FRA), Dinamo Zagreb (CRO)
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ