SAN FRANCISCO -- When the San Francisco Giants were compiling the best record in the National League in the first two months of the season, the second-base position provided a significant offensive contribution thanks to the power hitting of Brandon Hicks.

It has taken a while, but rookie Joe Panik seems to be fitting into Hicks' big shoes.

Panik, the Giants' new everyday second baseman, tripled and scored on Gregor Blanco's single in the eighth inning, capping a comeback that lifted San Francisco to a 6-5 victory over the Philadelphia Phillies on Saturday afternoon.

After losing 5-3 in 10 innings in the opener of the three-game series Friday night and falling behind 5-1 Saturday, the Giants used a four-run sixth inning and Blanco's second of two run-scoring singles to win for just the second time in the past eight games.

"We came alive," said Panik, who went 2-for-3 to raise his average to .410 in his last 11 games. "When you're in the playoff race and you have a tough one like (Friday) night, and then you fall behind in a day game after a night game ... it shows the character of this team."

Panik, who also contributed an RBI single in the sixth inning, led off the eighth with a shot to right-center field in the lefty-lefty matchup with the Phillies' fourth pitcher, Antonio Bastardo (5-7).

"My mindset was just to battle. I was facing a tough left-hander," said Panik, who is now 11-for-24 against lefties this season. "Just get on base. Just put it in play. I was fortunate to hit the gap and get to third on it."

Another left-hander, Jake Diekman, relieved Bastardo at that point and surrendered Blanco's tiebreaking hit, a hard grounder into left field. Blanco, a substitute left fielder who entered the game as a sixth-inning pinch hitter, finished 2-for-2.

Left-hander Jeremy Affeldt (3-1), the fifth Giants pitcher, got the win after working a scoreless eighth inning and getting Phillies first baseman Ryan Howard, who had three hits, to ground out to open the ninth.

Former closer Sergio Romo came on to retire two of the three batters he faced to post his first save since June 20 and his 23rd overall.

"We needed that," Panik said of the team's second win in the last three games, "especially after the way it started."

Left fielder-first baseman Michael Morse had two doubles and a triple for the Giants, who were outhit 13-11 by the Phillies.

Howard went 3-for-5 with a double and three RBIs. Philadelphia center fielder Ben Revere had a double among four hits.

The loss was the third in four games for the Phillies on their five-game California swing that concludes Sunday.

Howard had an RBI single in a two-run third inning and a two-run single in a three-run fifth as the Phillies sent Giants starter Tim Hudson to an early shower. Second baseman Chase Utley scored in each of the innings after a single and an RBI double.

Phillies manager Ryne Sandberg thought the game was lost in his team's three-run fifth and in the sixth, when his club left the bases loaded on back-to-back occasions with a chance to bust thing wide open.

"We had a solid game going into the sixth," he said, "other than the missed opportunities."

Down 5-1, the Giants rallied to tie the score in the sixth inning with the help of a dropped popup near the mound.

Morse drove in the first run of the inning with his first double, ending the day for Phillies starter Kyle Kendrick.

Panik had an RBI single off Phillies lefty reliever Mario Hollands, and Blanco did the same to Hollands' replacement, right-hander Justin De Fratus, to narrow the gap to 5-4.

Panik's hit scored third baseman Pablo Sandoval, who reached base when his high pop fly fell between Howard and Utley, with Utley getting an error for picking up the ball and throwing errantly to second base in an attempt to force catcher Buster Posey.

Center fielder Angel Pagan's sacrifice fly tied the score at 5.

"It was a combination of things ... (a lack of) communication and the sun and the wind," Sandberg said of the critical miscue on Sandoval's popup. "That seemed to be a momentum swing."

Neither starter got a decision.

Seeking his first win since July 25, Kendrick pitched five-plus innings, allowing four runs, only three of which were earned. He struck out one, walked two and allowed five hits, including a solo home run by Giants right fielder Hunter Pence to open the scoring in the bottom of the first.