Updated

Jason Castro tallied his first career multi- homer game in the Houston Astros' 7-6 win over the Milwaukee Brewers in the opener of a three-game set.

Brett Wallace and Castro hit back-to-back blasts in the fifth inning for the Astros, who have won four of their last seven contests.

"I'm just excited we won again and tried to knock somebody else out of the playoffs," Houston manager Tony DeFrancesco said.

Edgar Gonzalez (3-1) surrendered three runs on four hits over 5 2/3 frames to pick up the win.

Ryan Braun stole his 30th base to register his second consecutive 30/30 season in the setback.

Yovani Gallardo (16-9) allowed five runs -- four earned -- on eight hits and three walks for Milwaukee, which fell five games behind the St. Louis Cardinals for the NL's second wild card spot. The Cardinals defeated the Washington Nationals earlier on Friday.

Trailing 7-4 heading into the bottom of the ninth, Logan Schafer singled to start the frame and came home two batters later when Jason Segura lined a double down the left-field line.

Jonathan Lucroy then reached on Matt Dominguez's error at third base, which allowed Segura to come home, but Norichika Aoki grounded into a 6-4-3 double play to end the game.

"In the ninth inning, I felt real good that we could pull it out. Aoki doesn't hit into too many double plays," Milwaukee manager Ron Roenicke said.

Earlier, Houston struck first in the second on Dominguez's two-out RBI single to center field, but the Brewers got the run back in the third when Carlos Gomez launched a leadoff shot over the wall in left field.

The Astros then plated two runs in the fourth and fifth to take a 5-1 advantage.

Wallace came across in the fourth on Segura's error at shortstop and Gonzalez reached on a bunt single to plate Fernando Martinez.

Wallace and Castro smacked back-to-back blasts in the fifth for the Astros for the first time since Aug. 31.

Braun belted a two-out, two-run double in the sixth, which trimmed the deficit to 5-3, but Houston got a run back in the eighth on Castro's second homer of the night.

Aramis Ramirez launched a two-out RBI triple to right field in the home half, but Jose Altuve stroked a leadoff shot in the ninth, which gave the Astros a three-run cushion.

Game Notes

Braun hit 33 homers and stole 33 bases a year ago. He has a career-high 41 long balls this season ... Houston was 2-for-6 with runners in scoring position, while Milwaukee finished 2-for-8 with RISP.