City were eliminated at the quarter-final stage for the third year running last season and their latest attempt at winning the competition got off to a somewhat shaky start at the Etihad Stadium.
Diaz profited from some poor defending to race through and open the scoring but the Portuguese champions were pegged back after Pepe gave away a penalty from which Sergio Aguero converted, ending his longest goalscoring drought of 231 days.
Ilkay Gundogan scored a set-piece of his own with a dipping free-kick and close-season signing Torres netted five minutes after being brought off the bench as City turned the game on its head to make a winning start to their Group C campaign.
Porto had failed to score in their previous seven away encounters with English clubs in Europe but had to wait just 14 minutes for that drought to end.
Diaz embarked on an impressive solo run that saw him carry the ball from 45 yards out, evade a number of half-hearted challenges and drill a precise shot past Ederson.
City were given a chance to hit back six minutes later, however, as Pepe clattered into Raheem Sterling moments after Gundogan struck the outside of the post.
The penalty was awarded after a lengthy VAR check for a possible Gundogan foul on Agustin Marchesin, who got a hand to Aguero's spot-kick but could not keep it out.
Mateus Uribe fired over following a poor pass from Ederson and Kyle Walker hooked the ball off the line to spare Ruben Dias' blushes as Porto ended the first half on top.
The visitors dropped off slightly after the break and were undone in the 65th minute by Gundogan's set-piece brilliance, the Germany midfielder lifting the ball up and over the wall after being fouled by Fabio Vieira.
The game was put out of Porto's reach when Torres played a one-two with fellow substitute Phil Foden and crashed past Marchesin.
Following a scuffle between Sterling and Pepe, who had a running battle throughout, Rodri went close to adding a fourth late on as Marchesin pushed his 30-yarder onto the post.
What does it mean? Tenth time lucky for City?
City are competing in UEFA's flagship competition for a 10th successive season and are the favourites of some, despite only making it as far as the semi-finals on one occasion.
Questions remain of their defence on this first-half showing against Porto, but Guardiola will take pride from the way his players dug in and got the job done, even if it came at the cost of one of his most combative and experienced players, Fernandinho, being added to a considerable injury list during stoppage time.
City were all over the place at the back throughout the first half, not least for Diaz's impressive opening goal as the winger got away from Dias, Eric Garcia and Joao Cancelo.
Diaz lasted 55 minutes on his first appearance in the competition, managing more key passes (two) and winning more duels (12) than any player on the field in that time.
Pepe barged straight into Sterling inside the box - the fifth penalty he has conceded in the competition, which is more than any other player since data was first collected in 2003.
After a lengthy wait, Aguero stepped up and squeezed in the spot-kick for his 35th Champions League goal - only Didier Droba (36 for Chelsea) has managed more for an English side.
City return to Premier League action on Saturday with a trip to West Ham, while Porto host Gil Vicente in the Primeira Liga on the same day.