Raphinha opened the scoring for Barcelona on 53 minutes in Germany, latching onto a Dani Olmo pass on the counter, but Serhou Guirassy equalised seven minutes later from the penalty spot.
Torres, who replaced the ineffective former Dortmund striker Robert Lewandowski, tapped in a rebound with 15 minutes to play only for Guirassy to again haul Dortmund level.
With the hosts pushing for a first ever victory over Barcelona on their fifth attempt, Lamine Yamal fed Torres on a fast break and the winger drilled the ball past Gregor Kobel.
The win ensured Barcelona will reach at least the playoffs while putting them in pole position for a top-eight berth and direct qualification for the last 16.
Dortmund suffered their first loss at home in all competitions this season, sliding down to ninth in the Champions League table.
Beset by injuries, Dortmund coach Nuri Sahin named a surprise starting XI, opting for pace and youth to try and catch out Hansi Flick's high-risk, high-reward visitors.
Sahin handed Julien Duranville, 18, a starting debut while Gio Reyna started for the first time this season.
Raphinha caused Dortmund problems early and was inches away from a tap in before he blasted just wide with an open goal beckoning moments later.
When Dortmund did make it out of their own half, they did so through the fleet-footed Duranville, who found Marcel Sabitzer in a crowded penalty box but he blazed over.
The visitors' high defensive line was a pre-game target for Dortmund but the hosts were caught out early in the second half when Olmo put Raphinha in acres of space, allowing the captain to calmly dribble goalwards and slot a low shot home.
Pau Cubarsi gave Dortmund a sniff shortly after Barcelona took the lead, pushing Guirassy to the turf in the box and giving away an unnecessary penalty, which the Guinean converted.
Dortmund began played with renewed confidence but Barcelona struck on the counter, Torres slotting in a rebound after Kobel parried Fermin Lopez's volley.
The lead lasted three minutes as Yan Couto spotted an on-rushing Pascal Gross, with the former Brighton midfielder passing to Guirassy who rolled into an empty net after Inaki Pena came charging out of his area.
Barcelona snatched their fifth win in six games in Europe though as Yamal played in Torres, who atoned for a poor first touch by hammering low into the corner five minutes from time.
© 2024 AFP