HOUSTON -- Paul Maholm's big hit helped end a difficult stretch on the mound for the left-hander.
Maholm (4-2) allowed four runs and eight hits to pick up his first win since April 22 against Florida. He was 0-2 with five no-decisions in his previous seven starts.
"It's been frustrating," he said. "But you just have to understand that over 34 starts in a season, you're going to have little stretches like that. You just have to keep working and not let it bother you.
"Sometimes you give up four runs and win and sometimes you give up one and get a no-decision. That's just the way it goes."
Maholm went seven innings and allowed only one earned run in losing to the Astros just a week ago in Pittsburgh.
"He threw the ball well after a little bit of a shaky start tonight," Pirates manager John Russell said. "I think he got stronger as the game went on. His pitches got a lot better the last two innings."
Jack Wilson doubled twice and drove in a run and Andrew McCutchen delivered a two-run single for the Pirates, who snapped a five-game losing streak at Minute Maid Park. Adam LaRoche and Andy LaRoche each had two hits.
John Grabow worked the eighth and Matt Capps finished for his 13th save in 15 tries.
Roy Oswalt (2-3) gave up six runs and nine hits in six innings for the Astros, falling to 13-7 with a 2.62 ERA in 26 career games, 25 starts, against the Pirates.
Oswalt had won seven of his last eight decisions against Pittsburgh. The six runs tied for the most the right-hander has allowed versus the Pirates, set July 16, 2002.
Hunter Pence hit a two-run homer in the first for the Astros but Pittsburgh responded with three in the second. Maholm hit a slow bouncer to second with the bases loaded that got past Oswalt and drove in Andy LaRoche. McCutchen followed with a single to right to make it 3-2.
Astros manager Cecil Cooper said Maholm's dribbler was a big turning point.
"Roy probably should have made that play," Cooper said. "Roy will tell you he probably should have made it. It's big because if he makes the play, we're out of the inning with zeros. It got away from him a little. It was one of those nights."
Oswalt didn't make any excuses.
"I thought I had it but the ball went through my glove," he said. "I pitched myself into that trouble. That was probably the most out of place I've ever felt on the mound during the second and third innings. I couldn't throw the ball anywhere I wanted to. I was scared to throw a breaking ball."
The Pirates also scored three times in the third. Brandon Moss and Wilson had RBI doubles, and Jason Jaramillo drove in a run with a groundout.
Pence tripled and scored on Carlos Lee's groundout in the bottom half, and Lee added an RBI single in the fifth.
3B Andy LaRoche returned to the lineup after missing one game with a bruised right knee contusion. ... Astros reliever Geoff Geary will stay with the team as he rehabs his biceps tendinitis. ... Astros 2B Kaz Matsui, on the disabled list since May 26 with a left hamstring strain, has been doing some light running and fielded grounders before the game. He could return by the middle of next week. ... Wilson's double in the third gave him 25 career hits against Oswalt, the most by any opponent. Cardinals slugger Albert Pujols is second at 23.