MILWAUKEE — Eric Thames wanted to avoid extra innings.

One swing later, it was over.

Thames hit a game-ending homer to lift the Milwaukee Brewers to a 6-5 victory over the Texas Rangers on Friday night after Josh Hader blew a save opportunity for the fourth time this season.

"We're just happy to not have to go extras," Thames said. "We have two more games (in the series) so we need our arms in the bullpen. We can't waste everyone in one night."

Milwaukee earned its fourth straight win and moved within 2½ games of NL Central-leading Chicago, which lost 5-2 at Cincinnati.

Milwaukee opened a 5-2 lead with three runs in the seventh, but Logan Forsythe hit a two-run homer off newly acquired reliever Jake Faria in the eighth and Elvis Andrus' solo shot off Hader tied it at 5 with one out in the ninth.

Enter Thames, who hit his 16th homer against Emmanuel Clase (0-1) with two out in the bottom half. Thames was mobbed by his teammates at the plate after ending a game that lasted more than 4 hours.

"Thames is a pretty good hitter," Texas manager Chris Woodward said. "He's good at shortening his swing and getting the barrel to the ball."

Hader (2-5) threw a season-high 44 pitches in 1 2/3 innings. The All-Star left-hander has allowed a home run in three of his last five appearances, but Thames said he isn't worried.

"Josh has a nasty fastball with life on it," Thames said. "If guys aren't sitting on that pitch, they're not going to hit it. Some guys get lucky and they connect. He's still the best pitcher I've seen in the big leagues. You can't strike everybody out."

Hunter Pence also homered for Texas, which has dropped three in a row. Kolby Allard, who was acquired last week in a trade with Atlanta, allowed two runs and three hits in 4 1/3 innings in his Rangers debut after he was called up from Triple-A Nashville.

Milwaukee jumped in front on Ryan Braun's two-out RBI double in the first, but Pence responded with a 449-foot drive off Gio Gonzalez in the fourth.

The Brewers had a 2-1 lead before the Rangers tied it again in the sixth. With the bases loaded after three consecutive two-out walks, Pence scampered home on Alex Claudio's wild pitch, but Rougned Odor was cut down at the plate trying to come home on the same play.

Odor had four of Texas' 10 walks. Pence walked twice.

Yelich out again

Milwaukee outfielder Christian Yelich was held out for the third consecutive game due to nagging back soreness. The Brewers, who had Thursday off, had hoped the rest would allow the reigning NL MVP to play in the series opener.

“I think we’ve turned the corner a little bit,” manager Craig Counsell said. “Optimistic on the weekend, but not 100 percent.”

Perez returns

The Brewers promoted Hernan Perez from Class AAA San Antonio and optioned third baseman Travis Shaw to their top farm club. Perez started at shortstop. The team also designated right-hander Burch Smith for assignment.

The Rangers optioned outfielder Scott Heineman to Class AAA Nashville to make room for Allard. They also traded left-hander Miguel Del Pozo, who has spent this season at Nashville, to the Los Angeles Angels for cash considerations.

From the infirmary

The Rangers’ Isiah Kiner-Falefa and Willie Calhoun both remained in the game after being hit in the upper back by Hader fastballs.

Brewers right-hander Zach Davies, on the injured list with back soreness, is improving, Counsell said. “Our goal is to test him pretty hard a couple times,” he said. “We don’t want him pitching with some discomfort. I think that’s hurt him in the past.” ... Right-hander Brandon Woodruff (left oblique) played catch for the first time since going on the injured list last month.

Trio honored

Closer Trevor Hoffman, shortstop J.J. Hardy and second baseman Rickie Weeks were honored on with induction to the Miller Park Wall of Honor, an installation meant to inspire memories of the players who wrote the history of the franchise. The pregame ceremony delayed the start of the game until 7:29 p.m.

“It’s a great night, personally, for me to see those guys,” Counsell, who played with all three inductees and was behind the creation of the Wall of Honor in 2014. “These guys were three great Brewers, they really are.”

Up next

Pedro Payano (1-0, 3.45 ERA) is scheduled to make his third major league start against Milwaukee on Saturday. The Brewers will counter with Adrian Houser (4-5, 4.24 ERA), who will make his ninth start of the season and first of his career against the Rangers. Houser is 0-5 with a 6.82 ERA as a starter this season.