PHILADELPHIA — Red Sox right-hander Daniel Bard is still adjusting to being a starting pitcher.

Bard, a career reliever moved into the rotation before this season, matched his shortest outing of the year, allowing five runs in five innings as Boston suffered a 6-4 loss to the Philadelphia Phillies on Friday night.

The right-hander allowed just three hits but walked five. He struggled with his control in the first inning, when the Phillies scored four runs on three walks and two hits.

“I’m still getting out of my relieving mode and I needed to be more aggressive there,” Bard said of the first inning. “This loss is definitely on me.”

Bard (3-5) was thought to be the replacement for closer Jonathan Papelbon, who signed a four-year, $50 million deal with the Phillies in the offseason. But when Boston signed All-Star closer Andrew Bailey, Bard was switched to a starter and stayed there even after Bailey’s injury in spring training that has kept him out all season.

It’s still a work in progress for Bard.

“I think the first mistake was the 3-2 slider to the leadoff man,” Bard said, referring to Jimmy Rollins’ leadoff walk. “I tried to power through it, but you can’t do that early in the game. It took me too long to get back into it.”

Red Sox Manager Bobby Valentine said: “Those amount of walks are not acceptable. He just didn’t have command.”

Bard’s counterpart, Cole Hamels, didn’t have command problems, and it was no surprise that Philadelphia earned its season-best sixth straight victory with Hamels on the mound.

Hamels pitched seven strong innings, and Hunter Pence and Freddy Galvis homered to lead the Phillies.

Hamels (6-1) gave up three runs on six hits while striking out nine and walking one. It was the sixth straight win for Hamels, who improved to 4-0 in five career starts against Boston.

“I’m just doing everything I’ve done the past couple of years,” Hamels said. “I can’t say there’s any secret. We’re able to battle and get runs and I’m able to hold it. It’s the same sort of way I’ve gone out and pitched. I try to put up as many zeroes as I possibly can.”

Philadelphia improved to 7-1 in Hamels’ eight starts this season.

“I’m focused on trying to get wins, no matter how they come,” Hamels said. “If I can plug away and do my job, then good things will happen and they have been.”

Carlos Ruiz went 2 for 3 with a pair of RBI for Philadelphia, which moved two games above .500 for the first time this season. Ruiz, who leads major league catchers in several offensive categories, is 11 for 17 in his last five games.

Papelbon pitched a scoreless ninth for his 12th save in as many chances. Papelbon had 219 saves in six seasons with the Red Sox.

The closer said there wasn’t any extra meaning in getting the save against his former team.

“I want to go out there and try to preserve all the wins I can for my starters,” Papelbon said. “I think for me, I take a little extra pride in that. That’s basically kind of what it boiled down to for me.”

Adrian Gonzalez, Mike Aviles and Cody Ross homered for the Red Sox.

Philadelphia went up 2-0 on Ruiz’s two-run single to center before Ty Wigginton’s sacrifice fly and John Mayberry Jr.’s RBI double gave the Phillies a four-run lead.

Boston got a run back in the third on Aviles’ homer to left. The Red Sox put runners on first and second with no outs in the fourth, but got just one run on Daniel Nava’s sacrifice fly.

Ross homered in the sixth, and Gonzalez made it 5-4 in the eighth with his first homer since April 17.