MINNEAPOLIS (AP) — Jose Miranda hit a game-ending, three-run homer against Milwaukee’s Josh Hader as the Minnesota Twins finally got a timely hit to beat the Brewers 4-1 on Wednesday.

Miranda’s third hit of the game traveled to the second deck in left field. The 23-year-old rookie knew it was gone as he threw his bat and looked at the Minnesota dugout before the ball landed. The Twins have five walk-off wins this season.

Hader (0-3) walked Jorge Polanco and allowed a single to Max Kepler before Miranda’s drive.

Jhoan Duran (1-3) earned the first win of his career with one inning in relief, allowing one hit and a walk. Milwaukee had runners on first and second in the ninth inning, but Jace Peterson grounded into a 3-6-3 double play to end the threat.

Peterson homered earlier for the Brewers’ lone run.

Minnesota had plenty of chances to put the game away, but the Twins were 1 for 10 with runners in scoring position and left 13 runners on base through the first nine innings.

FOR STARTERS

Joe Ryan gave up just two hits in 5 1/3 innings for Minnesota. He allowed Peterson’s solo homer leading off the third.

Aaron Ashby struggled to put away Twins hitters — until it mattered. In his third start since coming off the injured list for left forearm inflammation, Ashby threw 101 pitches in 4 1/3 innings. He surrendered six hits and walked three but allowed just one run.

Minnesota left seven runners on base in the first four innings against the left-hander, but Ashby’s day was done after a pair of one-out singles in the fifth. Trevor Gott came on in relief and stranded both runners.

TRAINER’S ROOM

Brewers: OF Christian Yelich missed his second straight game with mid-back tightness.

Twins: RHP Joe Smith was reinstated from the 15-day injured list after recovering from upper trap tightness. RHP Josh Winder was optioned to Triple-A St. Paul. … RHP Chris Archer, on the 15-day injured list with left hip tightness, is lined up to start Sunday.

UP NEXT

Brewers: RHP Corbin Burnes (7-4, 2.20 ERA) opens Milwaukee’s four-game series in San Francisco on Thursday. The Giants will counter with LHP Carlos Rodón (8-5, 2.70) in a matchup of two starters headed to the All-Star Game.

Twins: RHP Sonny Gray (4-2, 3.03) starts Thursday as Minnesota hosts the White Sox for a four-game series. Gray surrendered a season-high five runs in 4 2/3 innings against Texas in his last start. Chicago is scheduled to start RHP Johnny Cueto (3-4, 2.91).