The win gave Houston its first three-game series win since taking two of three from the Royals on May 20-22, a span of four series. The Astros finished a week-long homestand with a 5-2 record and head to Chicago for a three-game set against the Cubs.
"What a ballgame," Pena said. "What a great homestand we just had. We were in every single game and won most of them. To end the homestand in such a way like this is very powerful. It gives us a lot of momentum going forward."
With runners on second and third and one out in the 10th, Pena sat on the first pitch from Brewers lefty Michael Gonzalez and drilled it well over a drawn-in outfield and beyond the right-field fence. It was the sixth walk-off homer of Pena's career.
"It never gets old," said Pena, who received the brunt of the Astros' raucous celebration after he crossed home plate. "That was great. I got beat up a little, all kinds of substances were poured all over me. Gatorade, ice water, shaving cream, you name it. I was pretty sticky and messy."
Catcher Carlos Corporan played a key role down the stretch, launching a towering solo homer to tie the game at 4 in the eighth inning and corralling a wild pitch in the ninth to initiate a rundown between third and home that secured the third out.
"Corp did a great job and called a great game," said Astros manager Bo Porter. "Obviously, there was the big homer to tie the game. It gets lost in the excitement, but each and every time our pitchers got into tight spots, he did a good job of settling the situation and making sure we got the right sequence going."
The Brewers hopped out to a 3-0 lead in the second, using a pair of two-out Houston errors to plate a trio of runs and frustrate Houston starter Lucas Harrell.
With that lead, Milwaukee starter Yovani Gallardo cruised until the fifth, when a walk, a single and a passed ball put Astros on second and third with one out.
Matt Dominguez and Trevor Crowe grounded into consecutive fielder's choices to narrow the lead to 3-2. Crowe left the game in the next inning, smashing his shoulder into the wall while trying to rob Jonathan Lucroy of a solo homer that made it 4-2.
Crowe was placed on the 15-day disabled list after the game with a sprained AC joint in his right shoulder.
Matt Dominguez added an RBI double in the sixth inning to cut the Brewers lead to 4-3. Dominguez now has nine RBIs in his last five games and 41 this season, a team high.
Lucroy's shot ended Harrell's outing, and the Astros' bullpen navigated out of some tight spots to make Corporan's homer count.
Gallardo didn't shut down the Astros, but solid contact resulted in many line-drive outs, and he never allowed multiple baserunners at once outside of the fifth inning. He lasted seven innings, getting a no-decision while giving up three unearned runs with six strikeouts.
It was an odd and messy contest, as the teams combined to commit four errors, hit two batters, throw a pair of wild pitches, and surrender a passed ball. They hit just 1-for-20 with runners in scoring position. Astros pitcher Josh Fields pinch-ran in the 10th inning and scored the winning run on Pena's homer -- which was the lone hit with runners in scoring position.
"For me," Milwaukee manager Ron Roenicke said of his team's performance, "that's as bad as it gets."
Porter agreed that neither team exactly seized the game, but he did enjoy the Astros' "resilience."
"If you look at the mistakes we made early, it could've been something where we held our head down, but not this group here," Porter said. They kept fighting and found a way to get the game tied, and then Carlos came through."
The Brewers put multiple baserunners on in the seventh and eighth innings and had a runner on third with one out in the ninth. Milwaukee couldn't plate a run in any of those frames and were twice tagged out between third and home.
"That's the impressive part to me," Pena said. "We have all these pitching performances worthy of mentioning. Jose Cisnero, [Hector] Ambriz, Jose Veras, those guys came in and worked through difficult situations. We don't get to the end like we do if those guys don't come through."
That bullpen effort kept Harrell off the hook for a loss after he tossed 5 1/3 innings with just one earned run and three strikeouts.
That makes nine starts this season in which Harrell has surrendered one earned run or fewer, second in the American League only to Mariners ace Felix Hernandez.
"I'm back to getting my mechanics like they were last year," Harrell said. "I was inconsistent early in the year, but now I haven't been walking anybody. I was just battling today, trying to keep the team in it. It was one of those days you had to bear down and grit it."
Chris Abshire is an associate reporter for MLB.com.