Updated

Kyle Kendrick tossed a gem after a disastrous start.

Casey McGehee hit a three-run homer during a five-run first inning off Kendrick and the Pittsburgh Pirates beat the Philadelphia Phillies 5-4 Thursday.

A.J. Burnett threw 6 2-3 sharp innings to win his eighth straight start and Pedro Alvarez also went deep for Pittsburgh, which split the four-game set in Philadelphia by winning the last two. The surprising Pirates, seeking their first winning season since 1992, are 40-35 and second in the NL central.

Burnett (9-2) allowed three runs and six hits, striking out seven. The winning streak is his longest, and it's the first time a Pirates pitcher has won eight in a row since Dock Ellis in 1974.

Kendrick (2-8) settled down nicely after giving up five runs before recording two outs. He gave up five runs and six hits in seven innings.

"Gave us a chance to win, pitched deep into the game, which they needed me to," Kendrick said. "We just came up short."

Overcoming a 5-0 deficit is difficult for most teams, especially those missing some of their big hitters.

"The five runs got us behind and took a little starch out of us," Phillies manager Charlie Manuel said. "That lets a little air out of the bubble, especially in day games."

Joel Hanrahan tossed a scoreless ninth for his 20th save in 22 tries. He retired Hunter Pence on a shallow fly with the tying run on third to end it.

Eric Kratz and Pence hit homers for the Phillies.

Drew Sutton led off with an infield single and Neil Walker walked. One out later, Garrett Jones hit an RBI single.

McGehee followed with a three-run shot to left. Alvarez then lined one out to right to make it 5-0.

Kratz connected off Burnett in the second to cut it to 5-2.

Burnett retired nine straight before consecutive singles by Shane Victorino and Pence put runners on first and third with one out in the sixth. Placido Polanco's fielder's choice grounder scored Victorino to cut it to 5-3.

Pence led off the bottom of the eighth with a shot off Jason Grilli for his first homer since June 2 and 14th of the year. Pence snapped a 98 at-bat homerless drought.

Grilli pitched out of a jam with two runners on to preserve the lead. He struck out pinch-hitter Jim Thome and retired pinch-hitter Carlos Ruiz on a foul pop. First baseman McGehee made a nice running catch and held onto the ball after stumbling into the first row down the right-field line.

"We definitely had chances to win the game, but couldn't get the big hit," Manuel said.

This was Burnett's first appearance in Philadelphia since losing to Cliff Lee and the Phillies in Game 5 of the 2009 World Series. Burnett beat Pedro Martinez in Game 2 that year and the New York Yankees prevented the Phillies from repeating as world champions by taking the Series in six games.

The Phillies finished 5-5 on their longest homestand of the season. The five-time defending NL East champions fell to last place and are 36-42, including 17-24 at home.

NOTES: Phillies designated RHP Chad Qualls for assignment and called up RHP Brian Sanches and LHP Jeremy Horst. ... 1B Ryan Howard is set to start a rehab stint at Class A Lakewood on Thursday night. The 2006 NL MVP hasn't played for the Phillies this season after tearing his left Achilles' tendon last October. ... The Phillies had their 261st straight sellout, including postseason games. ... Lee (0-4, 3.72) tries again for his first win when the Phillies open a three-game series in Miami on Friday night.

___

Rob Maaddi can be reached at http://www.twitter.com/RobMaaddi