San Francisco then countered in the 10th while facing Anthony Bastardo (1-1).
Posey, pinch-hitting for Brandon Belt, led off with a single, went to second on a Joaquin Arias sacrifice bunt and to third on a wild pitch.
After Brandon Crawford walked and Guillermo Quiroz struck out, Torres delivered a solid hit to right field, driving in the game-winner.
Javier Lopez (1-0) earned the decision with a scoreless top of the 10th for the Giants, who salvaged one win in their three-game series.
Hunter Pence socked a solo homer for San Francisco.
Kevin Frandsen went deep for Philadelphia.
Man spent 15 hours in jail for plugging electric car into an outlet at a school
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'