Hanrahan had converted 28 straight save chances dating to last year.
"Fortunately, we kept it right there at the tie game and guys battled and we had some things working," he said. "Sometimes you need a little extra time. The guys came back in the bullpen and did their job at the end, and it's always nice winning a series and it's good to go home with."
Brandon Wood doubled to start the 11th and was replaced by Harrison. Xavier Paul reached on an error when Houston closer Mark Melancon (5-3) couldn't handle his one-out dribbler that sent Harrison to third.
"I make that routine play at first base, they have a guy on second with two outs," Melancon said. "Looking back, it seems like three or four things went wrong. It seems like that sums up our season a little bit. It's a game of inches, and we never get those inches. That's on us. It's not the way that luck falls, it's on us, but it's tough."
Presley said the Pirates were determined to win after Hanrahan's rare failure.
"Stuff happens, adversity, so we fight harder and grind harder and I think we've been showing that lately and showed it today," Presley said.
Hanrahan allowed an RBI double to Johnson that tied it 4-all in the eighth.
Jeff Keppinger singled off Jose Veras to start the inning. Hanrahan replaced him with two outs, and Johnson delivered his key hit. Johnson took third on a wild pitch, but Hanrahan struck out Brian Bogusevic to limit the damage.
Hanrahan pitched a 1-2-3 ninth before Chris Leroux (1-0) allowed one hit in a scoreless 10th for his first major league win. Chris Resop allowed a solo homer to Quintero in the 11th, but got his first career save.
"They're human," Pirates manager Clint Hurdle said, referring to Hanrahan. "He got a pitch in the spot that Johnson could drive it, the runner's moving on the pitch, it happens. It's going to happen. He hasn't given up much. He's given up some hits, but he responded professionally the next inning just as big to go out and shut them down."
Presley had an RBI single in the fourth and put the Pirates on top 4-3 with his run-scoring double in the sixth.
Houston manager Brad Mills was ejected for arguing balls and strikes on an at-bat by Keppinger in the third inning. Keppinger, who finished a triple short of the cycle, homered for the second straight day when he launched a two-run shot that gave Houston a 3-2 lead two pitches later.
Astros starter Wandy Rodriguez allowed eight hits and four runs while matching a career high with 11 strikeouts in 5 2/3 innings.
Pittsburgh starter Kevin Correia yielded five hits and three runs in six innings and drove in a pair of runs with a double in the second.
Wood doubled in the sixth to set up Presley's double that chased Rodriguez.
The Astros had a chance to add runs in the seventh but McCutchen ended the threat with a sliding catch of Clint Barmes' fly to shallow center. McCutchen caught the ball as he fell to his back and remained on the ground for a moment, smiling with the ball in his glove.
Keppinger doubled and scored on a single by Hunter Pence to give the Astros a 1-0 lead in the first.
The Astros placed INF Matt Downs on the paternity leave list and purchased the contract of LHP Wesley Wright from Triple-A Oklahoma City after the game. ... Houston's Carlos Lee was shaken up in a collision with McCutchen in the 11th. Lee was jumping to grab a high throw to first when McCutchen crashed into him, sending Lee face down to the dirt. He remained there for a couple of minutes and was checked out by trainers before getting up and remaining in the game. Mills said Lee was OK. ... Pittsburgh SS Ronny Cedeno, who has been on the 7-day concussion disabled list since July 2, started a rehabilitation assignment with Triple-A Indianapolis. Hurdle said he would like Cedeno to play at least four games and that he could return for the team's series with St. Louis, which begins Friday. ... Hurdle said C Ryan Doumit, on the 15-day DL with a broken left ankle, could go out on a rehabilitation assignment sometime next week.