BOSTON -- Cole Hamels was at his best after losing a lengthy at-bat.
Hamels cooled off Boston's surging lineup with seven strong innings, helping the Phillies beat the Red Sox 5-3 on Sunday to salvage the finale of the weekend series.
Raul Ibanez hit a two-run homer for the Phillies, who snapped a six-game road losing streak with just their eighth win in their last 24 games overall.
Adrian Beltre hit his ninth homer for Boston, which plated double digits in each of the first two games of the series, winning by a combined score of 22-4.
Hamels (6-5) allowed one run and five hits, struck out eight and walked two, stopping a personal three-game skid. The left-hander has yielded three runs or less in each of his last eight starts.
It was an interesting contrast of pitchers between the hard-throwing Hamels and knuckleballer Tim Wakefield.
"When he's got a good fastball, that's when he's good. He was good today, man. He beat a good team," Phillies manager Charlie Manuel said. "They really work the count on you, and they'll take the ball the other way. They're a good team. They're very good."
Hamels' best inning may have been the sixth. He walked Victor Martinez on the 15th pitch of the at-bat, putting runners on first and third, but he got Beltre to bounce into an inning-ending double play.
"I probably should have drilled him on the first pitch. I'm just kidding," Hamels said. "He's a tough hitter and after a few pitches you just don't want to give in. You keep going after him and you're hoping that all of a sudden he starts sitting on a different pitch. I didn't want to make it easy, and after that it's just grinding away. It's going after the next guy."
Boston manager Terry Francona was impressed with how Hamels responded after Martinez's walk.
"For him to do what he did after that shows what kind of pitcher he is," he said. "That can take a lot out of a pitcher."
Wakefield (2-5) tossed 7 1/3 innings for Boston, allowing four runs and five hits. The 43-year-old right-hander also became the third active pitcher to reach 3,000 innings.
"That's pretty special," he said. "Unfortunately we lost today. We were facing a tough guy over there in Cole Hamels. Reaching 3,000 is pretty cool. There's not many guys that can say that."
Philadelphia, which had lost its last six games at Fenway Park, strung together five consecutive hits during its four-run fourth.
"I know this: I know we can hit," Manuel said. "We've been hitting for five or six years, I know that. We hadn't been hitting, but we're going to. I've got a lot of faith and confidence in our guys."
It was a welcome sight for Philadelphia, which has had trouble scoring the past few weeks.
Castro also hit a sacrifice fly in the ninth to make it 5-1.
Wakefield reached 3,000 innings when Shane Victorino flied out in the third, joining Philadelphia's Jamie Moyer and the New York Yankees' Andy Pettitte as the only active pitchers to reach the mark. Pettitte accomplished the feat on Friday night.
Red Sox OF Daniel Nava almost wasn't in the lineup one day after he became the second player ever to hit a grand slam on the first pitch of his initial major league plate appearance. But Francona elected to rest OF Mike Cameron, bothered by an abdominal strain. ... Nava still didn't have a name plate above his locker Sunday morning. ... The Phillies went 2-4 against the Red Sox this season, with Hamels getting both wins. ... Boston 1B Kevin Youkilis, hit on the right arm by a pitch Saturday, was given the day off. "He's a little sore," Francona said. ... The Phillies have Monday off before Roy Halladay faces New York ace CC Sabathia at Yankee Stadium on Tuesday. "That's going to be a pretty good matchup," Manuel said. "That'll be real good."