Max Kepler tied the game with a solo home run in the eighth inning and drove in Eddie Rosario with the winning run in the 10th as the Twins rallied to beat the Detroit Tigers, 5-4, Tuesday at Target Field.

The win pulled the Twins within a half game of American League Central-leading Chicago and kept Minnesota a 1.5 games ahead of the New York Yankees in the race for home-field advantage in the first round of the playoffs.

Byron Buxton and Mitch Garver also homered for Minnesota, which holds the fourth seed in the expanded AL playoffs with four games remaining.

Taylor Rogers (2-4) gave up the go-ahead run in the 10th but earned the victory. It was the Twins’ fourth walk-off victory of the season.

In the 10th, Rosario scored pinch-runner Jake Cave with a soft single to center off Bryan Garcia to tie the game 4-4. He stole second base as Garver struck out for the second out, but Kepler poked an opposite field single just over third base to score Rosario with the winning run.

They finish their season series with Detroit on Wednesday, then get a day off before playing host to Cincinnati this weekend. They already have clinched a postseason spot and are currently lined up to host the New York Yankees in a three-game series starting Tuesday.

Homer Bailey struggled in his first start since July 28 — the Twins reinstated him from the injury list (biceps tendinitis) before the game — and he struck out three batters in three innings and didn’t allow a hit until Castro’s single to center in the fourth inning.

But he also walked leadoff hitter Victor Reyes and gave up a run-scoring single to Miguel Cabrera that tied the game, 1-1. When Bailey walked Jeimer Candelario to load the bases, Twins manager Rocco Baldelli called on right-hander Cody Stashak to stanch the bleeding.

With the infield drawn in, Stashak got Brandon Dixon to ground sharply to shortstop Ehire Adrianza, who threw home to force out Castro. Catcher Mitch Garver then threw to third baseman Josh Donaldson to force out slow rolling Cabrera. Niko Goodrum then laced a liner into center that Byron Buxton caught near the warning track for the third out.

In their half of the inning, the Twins took a 2-1 lead on Garver’s home run into the second deck in left field, and they foiled Detroit’s attempt to tie it in the fifth when Eddie Rosario threw out Issac Paredes, who was trying to score from second on a single by Daz Cameron.

tinyurlis.gdu.nuclck.ruulvis.netshrtco.de