After blowing a two-run lead in the bottom of the ninth, the Giants responded quickly by pushing across a run in the next half-inning. Torres led off with a double off the Pirates' Octavio Dotel (2-1) and went to third on a wild pitch.
Sanchez, who finished 2-for-4 with two runs scored, then lofted a sac fly to center for a Giants lead.
Santiago Casilla got his first save for getting the final two outs in the bottom on the 10th. Starter Tim Lincecum allowed three runs on six hits over seven innings for a no-decision.
Garret Jones and Delwyn Young homered for the Pirates. Young's two-run shot in the bottom of the ninth tied the game for Pittsburgh, which ended up dropping the rubber match of a three-game series.