The Twins need a rest after Sunday's dizzying 12-9 victory over Detroit in 10 innings at Target Field.

They will get one now that they head into the four-day, All-Star break following a sweep of the Tigers in a four-game weekend series.

Not long ago, the Twins looked up at everyone from last place in the Central Division. On Sunday, they won their fifth consecutive extra-inning game after they started the season by losing their first eight.

This time, the Twins trailed 4-0 after five innings, led 8-5 after eight and then fell behind again following Tigers catcher Jake Rogers' ninth-inning grand slam.

But the Twins tied it up again when replacement rookie catcher Ben Rortvedt homered to make it 9-9 in the bottom of the ninth.

One day after he hit a go-ahead three-run shot in the seventh inning, Jorge Polanco delivered another, this time a walkoff shot to left in the 10th inning off Derek Holland, ending the game at 4 hours, 9 minutes on a breezy summer's day.

"That's why we love baseball, man," Twins starting pitcher Jose Berrios said. "Games like we have today."

It was Polanco's first career walkoff homer, his fourth career walkoff hit and 12th homer this season. It also gives the Twins now until Friday's doubleheader at Detroit to savor a game that careened everywhere until the final swing.

"You don't normally get to go into the All-Star break on such a high note," manager Rocco Baldelli said. "It's a great way for our guys to spend the next four days letting that build and thinking about the way we're playing right now. It's still a good time to take a break, so we can acknowledge it, feel it and come back ready to play."

All-Star break standings

The Twins scored in six consecutive innings — the fifth through 10th — for the first time since they beat San Diego 16-0 in September 2017. Their offense enabled them to overcome Berrios' fifth inning, when he loaded the bases and gave up a pair of two-out, two-run hits.

Berrios had not allowed a hit until those two outs in the fifth. He gave up just one hit and two runs his last time out, a loss to the Chicago White Sox on Tuesday.

"Frustrating," Berrios said after Baldelli stuck with him through scoreless sixth and seventh innings. "I don't want to say no it isn't, but that's baseball. You have to battle."

The Twins did, starting slowly with Max Kepler's solo homer in the fifth and Polanco's RBI single in the sixth. They added four more runs in the seventh — when the Tigers walked three batters and threw a wild pitch — and two more in the eighth to take an 8-5 lead into the ninth inning.

That's when Taylor Rogers entered, promptly loaded the bases and allowed Jake Rogers' first-pitch grand slam only 10 pitches in. Just like that, the Tigers led 9-8.

That is, until Rortvedt stepped forth. He entered for the injured Ryan Jeffers in the fifth inning. With one out in the ninth, Rortvedt hit a 1-2 pitch from Holland 410 feet for his second career homer.

BOXSCORE: Twins 12, Detroit 9 (10)

Baldelli called it an "enormous moment" for the rookie, who has a .132 average in 68 at-bats. "He continues to battle through whatever we put in front of him," Baldelli said.

Tyler Duffey pitched a scoreless 10th, thanks to first baseman Alex Kirilloff's diving, unassisted out that ended the inning. Polanco then finished the Tigers off with his blast.

"A real character game," Baldelli said. "You learn a little bit about yourself. You deal with a lot. There were a ton of different things that came up in that game. We dealt with whatever came our way, put some runs on the board, then put some more runs on the board. There was a lot going on and it ended in a big moment for Polo and the rest of the team."