"I figured sooner or later," Gaudin said about his RBI single in the third. "I'm pretty proud of that."
Gaudin was 1 for 58 before rolling a single through the left side. He was hitless in 17 at-bats this year, prompting him to take extra batting practice in San Francisco last week.
"Everybody kept asking me when I was going to get a hit," he said. "I figured I'd work on it. It paid off."
Neither team made a move as the non-waiver trade deadline passed Wednesday, a surprise considering both clubs are going nowhere.
The defending World Series champion Giants are last in the NL West. The Phillies entered 11 1/2 games out of first place and fell to nine back in the wild-card standings.
"I think it may have relaxed the guys," Giants manager Bruce Bochy said of the deadline passing. "We got a couple hits early and the confidence came back."
Gaudin (5-2) allowed one run and four hits, striking out five.
Roger Kieschnick had RBI singles in his first two major league at-bats for the Giants, who snapped a nine-game homerless drought when Pill went deep. Pill had three hits and four RBIs.
"The past couple games I kind of hit them where they weren't," Pill said. "There was a little luck involved."
Kyle Kendrick (9-8) gave up eight hits and seven runs in two-plus innings.
"I'm not going to make any excuse," Kendrick said. "I have to make better pitches. It was a frustrating night."
Chase Utley hit a solo homer for the Phillies, who snapped an eight-game losing streak with a 7-3 win in the series opener Tuesday.
The Giants jumped on Kendrick for four runs in the first inning, more than they had in any of the previous five losses.
Pablo Sandoval started it with an RBI on a bloop single. Pill hit a two-run single, and Kieschnick singled in one.
The Giants chased Kendrick with three in the third. Pill and Kieschnick had RBI singles before Gaudin got his single.
Pill and Crawford connected off J.C. Ramirez in the seventh.
Phillies third baseman Cody Asche started his first game, and his first fielding play was a sensational one. Asche made a diving, backhanded grab on Hunter Pence's hard shot down the line in the first, got up and threw him out with a strong throw.
Michael Young moved from third to first base to make room for Asche. The Phillies considered trading Young, but general manager Ruben Amaro Jr. stood pat for the first time in his tenure.
Fans sitting in the first couple rows down the right-field line escaped injury when Sandoval's bat shattered on a swing in the sixth and flew high in the air before landing more than 100 feet away. The broken part of the bat came down like a spear, but fans moved out of the way. Sandoval hustled out an infield single on the play, but left the game with a right heel bruise.
Sandoval is day to day. ... The Giants had nine runs total in their previous five games. ... Gaudin is 4-0 in five road starts. ... Buster Posey returned to San Francisco's lineup after missing a game with an upset stomach. ... Posey had the team's last homer on July 20. It was 90 1/3 innings before Pill hit his shot. ... The Phillies are 2-9 since the All-Star break. ... Kendrick's wife, Stephanie, gave birth to the couple's second child, Kyle Jr., on Tuesday. ... Cole Hamels (4-13, 4.09) faces Matt Cain (6-6, 4.79) in a matchup of struggling aces Thursday night.