SAN DIEGO — An offensive outburst commenced Friday with Freddy Galvis at the plate, asked to bunt two runners over for Brian Schneider in the seventh inning.

"Baseball is a weird game," Charlie Manuel said. He still wore his red Phillies jacket and could recline in his office as electronic dance music blasted in the clubhouse. They'll take it.

Related stories

The Phillies are back at .500 after a 4-1 victory over San Diego. They scored all four runs in the game's final three innings to finally support Cole Hamels. Luck turned with Galvis' bunt after singles by Shane Victorino and Ty Wigginton.

Schneider, hitless for the season, stood on deck and had to bat because Carlos Ruiz was sidelined with a sore wrist. Galvis bunted perfectly and the Padres botched the play. The bases were loaded for the backup catcher.

San Diego manager Bud Black emerged for a pitching change and Schneider turned back to the dugout. The Padres were warming a righty and lefty, so the lefthanded Schneider figured he'd face the latter. Then Jimmy Rollins told Schneider to expect heat from the righty Andrew Cashner.

"I was surprised," Schneider said.

Cashner, who routinely lights up the Petco Park scoreboard with triple-digit velocities, had retired the Phillies on seven pitches, all strikes, the night before. Schneider had eight at-bats to his name as he stepped in.

"I knew he had a good breaking ball," Schneider said, "and I was just trying to hit the heater right away."

It was 99 m.p.h. and knee-high. Schneider bounced it through the hole on the right side to tie the game.

Two batters later, Cashner hit 100 and 99 on the radar gun with a strike and ball to Juan Pierre. The slap-hitting Pierre's thinking never changed. "When a guy throws that hard, you have to stay on the fastball," he said.

Cashner then threw an 88 m.p.h. slider that Pierre smacked to right for a two-run single and the game's eventual winning hit. Pierre is hitting .316 in 38 at-bats this season and has firmly entrenched himself at the top of Manuel's lineup.

"I just put a good swing on it," Pierre said.

The Phillies remain in a tie for last place. It required five singles to score three seventh-inning runs. That represented progress, however, even if it's at the expense of baseball's worst team in San Diego.

For much of the night, it looked as if another Hamels start would fall by the wayside because of a lack of support. The lanky lefthander argued with the umpires and constantly pitched out of trouble in his hometown.

With Hamels out of the game during the rally, the triumvirate of Jose Contreras, Chad Qualls and Jonathan Papelbon secured a win. Contreras, making his first appearance in 307 days, issued a four-pitch walk to the first batter he saw. Then he induced a double-play ball and another grounder.

It was sweet for Hamels, who nearly lost his composure in a whacky outing. He was called for two balks, hit a batter, and pitched in tense situations for the majority of his six innings.

The second balk is what incensed Hamels. With Yonder Alonso on first and one out in the fifth, Hamels clearly stepped off the rubber. But Bob Davidson, the umpire they call "Balkin'" because his affinity for balks, called one.

"No I did not," Hamels yelled at Davidson. "I stepped off."

Davidson took exception and shouted back. Hamels stormed off the mound and Placido Polanco stepped between the umpire and pitcher to prevent any contact. Hamels bristled for a few moments.

"I can't let that affect me," Hamels said.

He was the first Phillies pitcher since Paul Quantrill in 1995 with two balks in one game. But the balks were nothing more than a nuisance, but did raise Hamels' pitch count.

San Diego cracked him when Cameron Maybin, mired in a two-week slump and the league's leader in strikeouts, tripled to the gap in right. The Phillies, despite their offensive anemia, were willing to concede the run and did when Jesus Guzman grounded to short. That snapped a streak of 21 scoreless innings by Phillies starting pitchers.

"I was fortunate enough," Hamels said, "to get away with a lot of bad pitches."

He completed only six innings but could have gone longer. On this night, it was acceptable for a Phillies starting pitcher to display mortality, thanks to an opportunistic offense.

Contact Matt Gelb at mgelb@phillynews.com or follow @magelb on Twitter.