HOUSTON -- The Reds were just two outs away from the kind of defeat that would have caused some serious tossing and turning in bed later. Two outs from letting nemesis Roy Oswalt mark another notch into his glove by the slimmest of margins.

Ramon Hernandez did just enough to flip that outcome. The catcher's first home run as a member of the Reds was a two-run shot in the top of the ninth that provided the 2-1 victory over the Astros on Friday night.

"Whew," Reds manager Dusty Baker exhaled. "That's a wonderful thing right there."

The Reds were down, 1-0, in the ninth when Edwin Encarnacion drew a four-pitch walk from Houston closer Jose Valverde (0-1). Up next was Hernandez, who sent a 1-2 Valverde fastball the opposite way to right field that landed in the first row of seats beyond the fence.

"I was lucky that ball got out," said Hernandez, who entered the night 4-for-23 (.174) this season with half of his hits coming in the previous game. "I was just trying to have a good at-bat and trying to get a single so I could get the inning going."

What he did instead was give Cincinnati a 3-1 record on a 10-game road trip with six games remaining.

"We were just hoping it was high enough to get out of here," Baker said. "Everybody was so happy when that ball disappeared."

The beginning of the game was a tight duel between Reds starter Johnny Cueto and Oswalt, who entered 23-1 lifetime vs. Cincinnati.

A golden chance to get Oswalt early was foiled as the Reds went 0-for-3 with runners in scoring position, stranding five through the first three innings. In the top of the second, the Reds had the bases loaded with one out but eighth hitter Alex Gonzalez and Cueto struck out.

Oswalt threw six scoreless innings, with five hits and three walks allowed. He struck out four and retired 10 of his last 11 batters.

Cueto held Houston hitless for his first three innings but lasted just 4 2/3 innings, allowing two hits. It was the six walks the right-hander gave up, especially three in the fifth inning, that derailed him from a better evening.

There were two outs and nobody on in the fifth when Cueto missed some close pitches and walked Oswalt. Cueto lost his composure and walked Michael Bourn on four pitches. Miguel Tejada's single loaded the bases. Lance Berkman walked for the third time in the game when he drew a full-count bases on balls from Cueto that forced home the first run. It was Cueto's final batter.

"That was huge. That was real big," Baker said. "That's prime evidence how walks will hurt you. It hurt us with Cueto and it hit hurt them walking Edwin."

It remained a 1-0 game because of the Reds' bullpen, which deserves a lot of credit for providing 4 1/3 innings of scoreless relief.

"That was the only reason we won the game, because if they don't hold that team back and they score more than two runs, my homer doesn't mean anything," Hernandez said.

After Cueto's exit, Mike Lincoln had his hands full with Carlos Lee and the bases still loaded. Lee was 5-for-7 (.714) in his prior meetings with Lincoln, but the reliever needed just two pitches to escape.

A curveball down in the strike zone was grounded by Lee to the shortstop for an inning-ending fielder's choice.

"He still put pretty good wood on that thing, but it went right to [the shortstop]. I can't complain," Lincoln said. Following Lincoln's 1 1/3-inning effort, Daniel Herrera worked two-thirds of an inning. Nick Masset (1-0) earned the victory with 1 1/3 scoreless innings.

"Each guy came in and did his job," Lincoln said. "That's what we have to do down there. The bullpen is pretty tight. We have a really good group of guys down there, and it feels like we could put any guy in any situation."

The Astros (3-7) did not go quietly as Reds closer Francisco Cordero gave up back-to-back one-out singles in the bottom of the ninth. Jason Smith followed with what was going to be routine pop fly that had Reds infielders scrambling when it hit the roof and redirected.

Gonzalez caught the ball but it was ruled foul and the at-bat continued.

"Some of the guys were upset," Baker said. "I said, 'No problem, that's better because we're going to get a double play.'"

That's exactly what happened. Smith grounded into a 4-6-3 double play that ended the game and gave Cordero his third save.

The Reds (5-4) have beaten Oswalt just once since 2001 and that happened almost three years ago on April 28, 2006. They missed slapping a big capital "L" next to the Astros ace's name.

"That would have been a real tough loss, especially since they really didn't deserve to win it, but they were winning," Baker said. "Especially when you walk in the only run and it's 1-0 against a tough Roy Oswalt."