PITTSBURGH (AP) -- Drew Sutton hit a one-out solo homer in the bottom of the ninth and the Pittsburgh Pirates improved to eight games over .500 for the first time in 20 years with an 8-7 win over the Houston Astros on Tuesday night.
Acquired via waivers last week, Sutton homered for the first time since Oct. 3, 2010, lifting the Pirates to their sixth walkoff win of the season, the first via a home run.
The Pirates rallied from deficits of 4-0 and 6-2 to take a 7-6 lead on a Garrett Jones two-run homer in the seventh. But with Houston down to its last strike in the ninth, pinch-hitter Jason Castro drove in Jed Lowrie with a double.
Andrew McCutchen continued his recent torrid pace by going 3 for 4 with a home run, taking over the National League batting lead at .360.
Sutton had three hits and Jones and Casey McGehee each had two hits for Pittsburgh (44-36), which has won six of seven.
Houston has lost six straight and eight in a row on the road.
The previous time the Pirates were this many games over .500 was at the end of the most recent season in which they had a winning record, 1992. A North American major professional sports record 19 consecutive losing seasons have followed.
Sutton took a 1-1 pitch from Wesley Wright (0-2) into the bullpen beyond the center field wall, capping a wild game.
Jones' line drive home run to right off Brandon Lyon in the seventh followed a McCutchen infield single. Jones homered for the second straight day and third time in the past five games to give him 12 on the season.
That appeared as if it was going to improve the Pirates to 17-5 in their past 22 home games until Castro's hit off closer Joel Hanrahan. It was the third blown save in 23 opportunities for Hanrahan (4-0).
A.J. Burnett's career-high eight-start winning streak - longest by a Pirates pitcher since 1974 - was snapped. He allowed six runs and 12 hits in five-plus innings but came away with a no-decision when the Pirates rallied against Lucas Harrell and Lyon.
Similar to teammate Jordan Lyles the day before, Harrell cruised through the first three innings but was hit hard after that. Harrell allowed only an infield single and had six strikeouts through three innings, but McCutchen followed a Sutton leadoff single in the fourth with his 16th home run and fourth in his past 10 games.
McCutchen is 7 for 9 in the series and 13 for 18 in his past four games.
Houston had taken a 2-0 lead in the second off the first of Schafer's two RBI singles and a Jose Altuve sacrifice fly. They added single runs in the third (Scott Moore's RBI double) and fourth (Lowrie's RBI single) and two in the sixth to answer the Pirates.
Not in the lineup for the second consecutive game after leaving Sunday's game in St. Louis due to leg cramps, Pedro Alvarez had a two-run single in the sixth to pull Pittsburgh back within 6-5.
Pittsburgh has homered in each of its past 11 games, the team's longest stretch since a 13-game streak June 19-July 3, 1994.
Notes: Dock Ellis was the previous Pittsburgh pitcher to win eight consecutive starts in 1974. Ellis also won 10 straight outings in 1971. ... Before the game, the Pirates recalled OF Gorkys Hernandez from Triple-A Indianapolis, optioning OF Jose Tabata to the team. Hernandez entered the game in the fifth inning to replace Alex Presley. Presley left the game due to concussion-like symptoms sustained while diving for a Lowrie hit in the first inning. ... Astros 3B Chris Johnson (left side strain) missed his third consecutive game. He hit off a tee and took ground balls Tuesday, and manager Brad Mills said it was possible he would return during this series. ... Mills said RHP Wilton Lopez (right elbow sprain) will go on a rehabilitation stint in the minors and soon thereafter be activated from the disabled list. ... Astros OF Justin Maxwell (left ankle) rejoined the team after electing against surgery and will go on a rehab stint over the All-Star break. ... Houston first base coach Bobby Meacham is away from the team for personal reasons. Matt Sinatro, the team's catching and advance scouting coordinator, is filling in. ... Wednesday's Pirates starter, RHP Kevin Correia, has never beaten the Astros in nine starts. Houston's LHP Dallas Keuchel (1-0, 1.35) will make his fourth career start.