Humberto Quintero scored on a most unlikely play to cap a Houston comeback and give the Astros a late lead.
Ryan Doumit put the Pittsburgh Pirates right back on top.
Doumit hit a three-run homer in the eighth inning and Pittsburgh improved to .500 this late in a season for the first time in six years, beating Houston 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.
"It was a little bit up," Quintero said of the 0-1 fastball Doumit hit into the left-field seats. "I don't think it was a bad pitch, but you have to give credit. He hit it."
Quintero is Houston's lumbering catcher who has one stolen base in 322 career games. But he scored from second base on a bunt single by pinch-hitter Angel Sanchez to cap a three-run Astros seventh.
Third baseman Brandon Wood picked up the ball just as Quintero was rounding third with no intention of stopping. Wood threw to first, but not in time to get Sanchez. First baseman Steve Pearce's throw home likewise did not beat Quintero.
"I got a big lead and I knew he was going to bunt so I tried to steal the base and go all the way down," Quintero said. "I don't people think I'm going to go home, so I went home."
"Quintero, he moved it," Sanchez said, laughing.
"I don't think that's in our playbook," Astros third baseman Chris Johnson deadpanned. "But a good heads-up play by him."
Quintero had tied the game with a double that scored Bill Hall. Hall's single followed Johnson's leadoff homer, his fourth of the season.
All this after the Astros had been shut out by James McDonald over six innings.
McDonald needed 96 pitches to get through his six innings and left with a 2-0 lead. The Pirates' Chris 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.
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."
Twice over the first four innings, Pittsburgh loaded the bases with less than two outs but each time scored only one run.
Pearce hit a sacrifice fly with one out in the first. 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 enough out of trouble 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," Pirates manager Clint 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."
It was the second straight game the Astros got a strong outing from a starter but failed to win. Bud Norris struck out nine in seven innings Saturday.
"I felt like I was making good pitches, but again I'd miss and they'd capitalize on it," Happ said. "They'd get a couple of hits and whatnot.
"I just definitely tried to battle the best I could. That's all you can do."
NOTES: 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 all-time on the franchise list. ... Johnson's fourth home run tied him with Pence for the team high.