HOUSTON -- Wandy Rodriguez's recent struggles caused him a lot of worry and some trouble sleeping.
"Today was a good game for my head," Rodriguez said. "I felt very good. I think about it when I pitch bad, but today my head is relaxed and I can sleep fine tonight and not think about it."
Houston won its first series over San Francisco this season and the first time the team has taken a set since winning three of four against the Rockies June 8-10.
"It's a good win for us today and a good series win for us," star slugger Lance Berkman said. "We've been looking for something to build on and hopefully this will be that thing."
Rodriguez (4-10) allowed four hits and two runs -- none earned -- in six innings to break a three-game losing streak. It's his first win since June 2 after allowing 17 runs combined in his losing skid. Rodriguez was helped out by double plays in the first, fourth, fifth and sixth innings.
"It is sure nice to get Wandy a win and he threw the ball well," Astros manager Brad Mills said. "It was nice to see. He made some adjustments and I thought he worked really good with [rookie catcher] Jason [Castro] behind the plate."
Giants starter Matt Cain (6-6) was knocked around for nine hits and seven runs, both season highs, in a season-low 2 2/3 innings.
"He was up," Giants manager Bruce Bochy said. "He had an off day and made some mistakes ... he had good stuff, he just made mistakes early. He's been throwing the ball as well as anyone in the major leagues with the roll he's been on."
Cain entered the game with a 2.16 ERA that rose to 2.72 after allowing the seven runs.
Aaron Rowand had a ground-rule double and scored on a single by Edgar Renteria that got San Francisco to 7-5 with one out in the ninth inning. Travis Ishikawa singled but Houston closer Matt Lindstrom retired the next two batters, striking out Juan Uribe swinging, for his 17th save.
"It's always nice to get on the board first, and having the 3-0 lead right away I think it gave Wandy a really good opportunity to work and the confidence to make good pitches," Lee said.
Castro, who made his major league debut Tuesday, hit his first home run -- a solo shot to right field -- in the second inning. The crowd rose for a standing ovation and his mother beamed as she snapped photos of him with a digital camera as he rounded the bases.
Rodriguez then singled and Michael Bourn doubled. Keppinger walked to load the bases setting up Lance Berkman's two-run double that pushed the score to 6-0.
Bourn drove in a run with a double with two outs in the third inning that chased Cain and made it 7-0.
"I felt I was getting behind into good hitters' counts and they took advantage of it," Cain said. "I had a chance in the first inning to get out of that situation and I made some bad pitches."
Bengie Molina reached on an error by Geoff Blum in the seventh inning before Rowand singled off Chris Sampson. Tim Byrdak replaced Sampson and retired the next two batters before an RBI single by Andres Torres made it 7-3. Huff followed with a run-scoring single off Byrdak. That got Byrdak replaced by Wilton Lopez and Uribe grounded into a force out for the third out.
The Astros placed RHP Felipe Paulino on the disabled list with right shoulder tendinitis before Thursday's game. The move will be backdated to June 21. RHP Josh Banks was called up from Triple-A Round Rock to take his spot on the roster and will start on Saturday at Texas. ... Houston RHP Bud Norris will come off the disabled list and start on Monday at Milwaukee.