Bryce Harper hit a two-run home run and a single while Bryson Stott added two hits for the Phillies, who have won two straight.
Philadelphia starter Taijuan Walker gave up six hits and three runs, two earned, with seven strikeouts and two walks in five innings.
Craig Kimbrel (7-3) earned the win after pitching a scoreless top of the ninth.
Joc Pederson led the Giants with two hits and two RBIs, and Thairo Estrada contributed three hits.
Giants starter Kyle Harrison lasted 3 1/3 innings in his major league debut. He allowed five hits and two runs with five strikeouts and one walk.
San Francisco All-Star closer Camilo Doval (5-4), who had converted 33 of 38 saves, allowed both runs.
Stott was hit by a Doval pitch on the elbow to open the bottom of the ninth. Pinch hitter Jake Cave popped out to shortstop before Brandon Marsh singled to center, with Stott advancing to third. Marsh then stole second and Kyle Schwarber was walked intentionally to load the bases. Turner then lined a 2-2 sinker to right field, ending the game.
The Phillies gained a 2-1 advantage in the bottom of the first when Schwarber led off with a double and Harper socked a two-out homer to right.
In the fourth, San Francisco's Patrick Bailey lined a shot that ricocheted off Walker's arm and into Turner's glove at shortstop for the second out. After a quick visit from manager Rob Thomson and the team trainer, Walker remained in the game.
Estrada doubled with two outs in the fifth and Flores walked. Pederson followed with a two-run double for a 3-2 Giants lead. On Pederson's hit, Phillies center fielder Johan Rojas made a diving attempt and nearly came up with a stellar catch.
—Field Level Media