Jose Altuve had a career-best four hits, and J.D. Martinez had three hits and three RBIs to lead the Houston Astros over the Brewers 7-5 Wednesday and stop an 11-game losing streak against Milwaukee.

Chris Snyder put the Astros ahead for good at 5-4 with an RBI single in the seventh off Jose Veras (2-1) after Brian Bogusevic doubled and stole third.

Wilton Lopez (2-0) pitched a 1-2-3 sixth, and Brett Myers got three outs for his third save. Houston, which hadn't beaten the Brewers since May 1, had 14 hits and won for the third time in 11 game overall. The Astros avoided a three-game sweep.

Martinez boosted the lead to 7-4 in the eighth with a two-run single off Mike McClendon.

Corey Hart hit a solo homer off David Carpenter in the eighth, when Wesley Wright induced an inning-ending flyout by to Cesar Izturis to Bogusevic, who made a sliding catch in right-field foul territory with two on.

David Carpenter had buzzed Carlos Gomez in seventh. Gomez ducked out of the way and glared at the pitcher. Brewers starter Shaun Marcum had hit Snyder leading off the second. Snyder walked to first, not even never looked at Marcum.

Astros starter J.A. Happ allowed four runs and seven hits in five innings with eight strikeouts, which tied his season high. Marcum had only one 1-2-3 innings and gave up four runs — three earned — eight hits and four walks in five innings. Marcum, who struck out seven, missed most of spring training with a sore right shoulder.

He left the bases loaded when Chris Johnson flied out ending the first and when Jed Lowrie flied out ending the fourth.

Ryan Braun hit a two-run homer in the first, then singled and the third and scored on Happ's wild pitch to tie the game 4-4. Travis Ishikawa, filling in at first for Mat Gamel, had homered leading off the second to cut Milwaukee's deficit to 4-3.

Gamel missed his second consecutive game with a sore shoulder after barreling into catcher Jason Castro, who also sat out for the second day in a row.

NOTES: Astros CF Jordan Schafer has reached base in all 19 games this season. ... The Brewers have allowed the opposition to score first in each of the last eight games and 14 of 19 games this season. ... The Astros are in a stretch of playing 13 of 16 games on the road. ... Izturis made his first major league appearance as a first base.