Updated

Carlos Ruiz smacked a go-ahead two-run single as part of a four-run sixth inning that vaulted the Philadelphia Phillies to a 6-4 triumph over the Pittsburgh Pirates Thursday in the rubber match of a three-game set at PNC Park.

Ben Revere went 3-for-5 with two RBI and Kevin Frandsen also knocked in a run for the Phillies, who earned their first series victory in Pittsburgh since April 25-27, 2008.

Cole Hamels (3-11) struck out eight and didn't walk a batter while limiting the Pirates to two runs -- one earned -- on five hits over seven stellar frames to notch the victory.

Jonathan Papelbon worked around a one-out single in the ninth to secure his 17th save of the season.

Gerrit Cole (4-1) became the first Pittsburgh pitcher to win his first four starts since Nick Maddox in 1907 with a win in his last outing, but the hard- throwing right-hander failed to make it five in a row after being tagged for three runs on eight hits over 5 1/3 innings to absorb his first career loss.

"I thought he pitched well," Pittsburgh manager Clint Hurdle said of Cole. "He's a 22-year-old young man. He's still learning, continuing to grow. He's fun to watch."

Andrew McCutchen plated a pair of runs for Pittsburgh, which had won nine straight games before dropping two-of-three to the Phillies.

McCutchen gave the Pirates an early 2-0 edge in the third when he ripped a two-out base hit back up the middle to score Starling Marte and Jose Tabata.

Philadelphia cut the lead in half in the fifth when Ruiz smacked a one-out single, moved to second on Hamels' sacrifice bunt, and scored when Revere slapped a single into center field.

The Phillies then seized control in the sixth, as Ryan Howard worked a one-out walk and Domonic Brown followed with a single to chase Cole from the contest.

"The Pirates have a really good bullpen but I think it made a difference when we were able to get Cole out of the game," Phillies manager Charlie Manuel said. "He's a good pitcher now and he's going to be a real good pitcher. He was tough."

Vin Mazzaro entered from the bullpen to face Delmon Young, who ripped a base hit to left to load the bases. Frandsen then looped a single into shallow right field to plate Howard and tie the game at 2-2.

Ruiz put the Phils in front for good when he followed with a line-drive single to left-center field to score Brown and Young for a 4-2 lead.

Mazzaro then hit Hamels on the foot to load the bases and end his brief outing, as Tony Watson took over on the mound. Frandsen then scored on a fielder's choice.

Philadelphia added an insurance run in the eighth, as Young laced a leadoff single before Frandsen was hit by a pitch.

After both runners moved up a base on a sacrifice, pinch-hitter Michael Young lifted a sac fly into left to plate pinch-runner John Mayberry for a 6-2 lead.

With Hamels done after seven strong, Justin De Fratus took over to start the home half of the eighth and issued three straight singles, the last off the bat of pinch-hitter Garrett Jones to plate a Jordy Mercer.

De Fratus then induced a double-play groundout from McCutchen, but a run was able to score from third to trim the margin to 6-4.

De Fratus escaped further damage by retiring Gaby Sanchez on a flyout before Papelbon shut the door on the Pirates in the ninth.

Game Notes

Pittsburgh won the season series 4-3 against Philadelphia for the second straight year, marking the first time since 2002 and 2003 that the Pirates have posted back-to-back winning seasons against the Phillies ... Hamels improved to 2-2 in seven career starts against Pittsburgh ... The Phillies have been victorious in nine of the last 10 years on Independence Day, with their lone loss coming to the Pirates at PNC Park in 2010 ... Philadelphia wrapped up a 10-game road trip at 5-5.