Updated

J.D. Martinez had three hits and three RBI on Wednesday afternoon and the Houston Astros snapped an 11-game losing streak to the Milwaukee Brewers with a 7-5 win.

Chris Snyder hit a go-ahead RBI single in the seventh inning and Martinez added a two-run base hit in the eighth for some cushion as the Astros salvaged the finale of the three-game series.

Wilton Lopez (2-0) earned the win with a perfect inning of relief for starter J.A. Happ and Jose Altuve had four hits and scored three runs. The first three hitters in Houston's lineup were 8-for-15 with four RBI and five runs scored.

"Those are the big hits that have been kind of eluding us a little bit," said Astros manager Brad Mills. "Any time you get guys at the top of the order driving the ball you're going to have opportunities to score some runs and that's what happened today."

Three of Milwaukee's 10 hits were home runs: Ryan Braun belted a two-run homer while Travis Ishikawa and Corey Hart added solo blasts.

Carlos Gomez hit a two-out triple in the ninth inning, but Astros closer Brett Myers held on for his third save.

Happ allowed four runs on two walks and seven hits while striking out eight in five innings. Brewers starter Shaun Marcum, who was 2-0 in three starts versus Houston last season, also went five frames and gave up four runs -- three earned -- on eight hits and four walks. He struck out seven.

"It was a tough one for both of us starters today," said Happ. "I really like the way the guys battled behind me. It was nice to jump on them early, but I wish I could have held them down a little bit better."

Brian Bogusevic hit a one-out double off Jose Veras (2-1) in the seventh, stole third base and scored when Snyder smacked an opposite-field single down the first base line to make it 5-4.

Veras had replaced Tim Dillard, who got three ground outs in a perfect sixth inning but was pulled for a pinch-hitter.

"It's the choices we have," said Brewers manager Ron Roenicke about taking Dillard out. "We felt that we needed to win the game or come back. We felt that we had enough arms in the bullpen."

The Astros tacked on two more runs in the eighth, starting with three straight hits off Mike McClendon. Jordan Schafer singled, went to third on Altuve's double and both runners scored on Martinez's base hit to center field.

Hart hit his sixth homer of the season off David Carpenter in the eighth and the Brewers put another runner on, but Bogusevic made a sliding catch near the stands in shallow right field on Cesar Izturis' foul pop up to end the inning.

Earlier, the Astros scored quickly after Altuve hit a one-out single in the first inning and scored on Martinez's double. They loaded the bases, but got no more runs.

Braun homered over the Milwaukee bullpen in left field in the bottom of the first to score Gomez, who had singled, but Houston re-took the lead in the second.

Snyder was hit by a pitch leading off, went to second on Happ's sacrifice bunt and scored on Altuve's base hit to spark a three-run rally. Carlos Lee added an RBI single in the inning and a run scored on Marcum's wild pitch to make it 4-2.

Ishikawa homered onto the concourse above right-center field leading off the bottom of the second, his second long ball of the season, and Braun scored on a Happ wild pitch in the third inning to tie the game at 4-4.

Game Notes

The Brewers were trying to sweep the Astros in a fourth straight series. Houston's last win versus Milwaukee came on May 1 last year...Milwaukee was 5-4 on a nine-game homestand and will start a nine-game road trip in St. Louis on Friday...The Astros will continue their six-game road trip at Cincinnati on Friday.