City was eliminated at the quarter-final stage for the third year running last season and its 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 champion was 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-seasonTorres netted five minutes after being brought off the bench as City turned the game on its head to make a winning start to its Group C campaign.
Porto had failed to score in its 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 was 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 visitor dropped off slightly after the break and was 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.