MIAMI (AP) — Newly acquired Twins reliever Sam Dyson caught a flight Thursday morning in Philadelphia, arrived at Marlins Park an hour into the game and found himself pitching in the ninth inning on three hours' sleep.

It showed.

Dyson blew a three-run lead without retiring a batter, and Harold Ramirez hit a leadoff homer in the 12th to send the Miami Marlins past Minnesota 5-4.

The AL Central-leading Twins revamped their bullpen after watching a whopping lead over Cleveland dwindle in the last month. Minnesota obtained reliever Sergio Romo in a trade with Miami over the weekend and acquired Dyson from San Francisco in a deadline-beating deal Wednesday.

Romo pitched a perfect eighth and turned a 4-1 lead in the ninth over to Dyson, who had a 2.47 ERA in 49 games for the Giants this season. Dyson faced four batters and allowed two walks, a single and an RBI double by Jon Berti before being pulled.

"It's a bad first impression," Dyson said with a chuckle. "Hopefully there are no more of those. I haven't walked too many guys this year — that's the bad thing of the whole situation. I didn't have it, and that's about it."

Twins manager Rocco Baldelli acknowledged he would be second-guessed for calling on Dyson.

"It made sense to get him in," Baldelli said. "It's a fairly high-leverage situation. He's going to pitch in big spots like that for us the rest of the year. I thought it fit well."

Ramirez hit his seventh homer against Cody Stashak (0-1) to avert a three-game sweep.

"Really, I just tried to get on base," Ramirez said. "I tried not to do too much because we needed someone on base."

The walk-off win was the Marlins' third this season, and all have come since July 18.

"Really excited about that win," manager Don Mattingly said. "We're proud of everything that happened today."

Max Kepler led off the game with his 30th homer and Byron Buxton drove in two runs with his 30th double for the Twins. But they struck out 15 times, and went hitless in their final 15 at-bats.

Minnesota's Michael Pineda allowed one run in six innings and departed with a three-run lead.

"Sometimes we have a bad game," Pineda said. "But this is a really good team and we're going to play better tomorrow, and we're going to win."

Neil Walker tied the game in the ninth with a two-run single off Taylor Rogers, but the left-hander struck out Jorge Alfaro and Bryan Holaday with the bases loaded to force extra innings. Miami won despite stranding 13 and going 2 for 10 with runners in scoring position.

Marlins starter Jordan Yamamoto allowed four runs in six innings.

MARATHON AT-BAT

Jeff Brigham (1-0) earned his first career victory with two perfect innings, including a 14-pitch showdown with Kepler, who flied out.

"That battle with Kepler was a lot of fun," Brigham said. "It kind of wore me out. I made some good pitches, and he made some good swings."

SLOW GOING

Twins slugger Nelson Cruz was out running from first to second in the ninth when he was unable to beat the throw from right fielder Brian Anderson, who had fielded Kepler's two-hopper.

ROSTER MOVE

Before the game, the Marlins recalled RHP Kyle Keller from Triple-A New Orleans.

TRAINER'S ROOM

Marlins: SS Miguel Rojas left the game with right hip tightness. His status is day to day.

UP NEXT

Twins: LHP Martin Perez (8-4, 4.38) is scheduled to start Friday when the Twins open a 10-game homestand against Kansas City.

More From KROC-AM