PITTSBURGH -- The Pittsburgh Pirates have steadfastly insisted that merely reaching .500 wouldn't be cause for celebration.
Ryan Doumit gave them a chance to find out what it feels like this late in the season for the first time in a while.
Doumit hit a three-run homer in the eighth inning and Pittsburgh evened its record later than at any point since 2005, beating the Houston Astros 5-4 Sunday.
Doumit's drive to left off Fernando Abad (1-3) was his third homer of the season. The Pirates have won five of seven and are 17-17.
"We know that this is a great thing for the city and we know that we are moving in the right direction," said Pirates third baseman Neil Walker, who grew up in suburban Pittsburgh. "I guess I understand it a little more than everybody else, because I was six years old in '92."
That was the last season in which the Pirates finished with a winning record. A North American major professional sports record 18 consecutive losing seasons have followed since.
The 2005 Pirates stood at 30-30 on June 11.
"We're on the road to where we want to go, and that would be one of the mile markers that you need to get by," first-year Pirates manager Clint Hurdle said. "And now we need to work on the shelf life and on pushing forward from here."
Pittsburgh built a 2-0 lead behind starter James McDonald's six shutout innings Sunday, only to have Houston erase a deficit and take the lead against its bullpen for the second time in the series.
Chris Johnson homered on Chris Resop's third pitch of the seventh, Bill Hall singled and Humberto Quintero followed with an RBI double. Quintero, a lumbering catcher, scored from second on a bunt single by pinch-hitter Angel Sanchez to put the Astros ahead. The Astros made it 4-2 on Brett Wallace's sacrifice fly off Daniel McCutchen (1-0) in the eighth.
Last-place Houston has lost four of five.
"We're playing well right now," Johnson said. "We've just got to figure out a way to make sure we get these wins in these close ballgames, because we're playing a lot of close ballgames."
McDonald had a shutout going but needed 96 pitches to get through his six innings and left with a 2-0 lead. Resop did not retire a batter and was charged with three runs in the seventh, two days after not retiring a batter and allowing two runs while working with a 2-1 lead in the eighth.
Joel Hanrahan closed, making him 10 for 10 in save opportunities.
Hunter Pence's first-inning single extended his hitting streak to 12 games, but McDonald retired the next 12 batters and struck out eight overall. McDonald, who allowed three hits, has allowed only two runs over his past three starts combined.
"I am feeling more comfortable," he said. "I had a good breaking ball today and the fastball was pretty good. I've got to keep working in doing the things that make me successful."
Twice over the first four innings, Pittsburgh loaded the bases with less than two outs but each time scored only one run.
Steve Pearce hit a sacrifice fly with one out in the first. Brandon Wood struck out with three on and nobody out in the fourth. Ronny Cedeno followed with an RBI single, but McDonald hit into a double play to end the inning.
Houston's J.A. Happ pitched effectively through six innings and was on the cusp of benefiting from a late-inning rally. Happ allowed 10 baserunners in six innings but gave up only two runs.
"Happ worked around a lot of baserunners, giving us a chance to win, and he did," Astros manager Brad Mills said. "He put us in position, and the guys did a great job coming back, putting us in a great position."
Until Doumit came to the plate in the eighth thinking home run all the way with two on and his team down two runs.
"Man, did he whack that thing," Hurdle said. "He caught that thing right on the barrel. What a big swing for us, especially the way things were kind of spinning the wrong way. He put a foot down and kind of changed the direction of the game."
And maybe -- maybe -- even the direction of the season -- and of a franchise that is so desperate to return to winning baseball.
"We know what we are capable of, and as far as we are all concerned, we haven't been hitting on all cylinders quite yet," Doumit said. "There's plenty more left in the tank. Back to .500 right now and we have a big series coming with the Dodgers. This one feels good."
Pirates 3B Pedro Alvarez did not start for the fourth consecutive game because of a strained right quad. ... Doumit's homer was his 50th as Pirates catcher, third on the franchise list. ... Johnson's fourth home run tied him with Pence for the team high.