– The Twins have taken punches this season but know how to counter. It’s a good trait for a division-leading team.

And Friday’s 8-7 win over the Royals exemplified just how they have avoided losing three consecutive games all season. No other MLB team can say that.

After looking sluggish in a loss the night before, the Twins fell behind by three runs two different times Friday before they snapped to attention midgame and shot past Kansas City.

VideoVideo (00:41): The Twins rallied to win on Friday, but Martin Perez put them in a three-run hole twice

Miguel Sano, in an 0-for-18 skid during which he had struck out 14 times, hit a game-tying home run in the seventh on a 97-mph fastball from Jake Diekman. That triggered a three-run inning, as Max Kepler and Eddie Rosario came through with RBI singles — Rosario’s coming after consecutive plays in which runners at third were tagged out in rundowns — as the Twins took an 8-6 lead.

After Jorge Soler led off the eighth with a home run to close the gap to 8-7, Twins manager Rocco Baldelli went with lefthander Taylor Rogers. Six outs later, the Twins had their win.

They were far from perfect Friday but made plays late.

“I saw a lot of what we’ve seen several times over this year,” Baldelli said, “and in a situation where things didn’t go totally smoothly at all points of the game, especially early, our guys kept plugging away and continued to just do what we’ve done and have good at-bats and go out there and just do what you have to do to get people on base and eventually win the game.

“We saw several good at-bats. We saw several moments where guys came through to get it done for us, and I anticipate we’re just going to see that going forward.”

The Twins trailed 3-0 after the first inning but scrambled back to tie the game before lefthander Martin Perez, winless since May 23, faltered in the fifth. Trying to work out of a two-on, no out jam, Perez struck two out, but Cheslor Cuthbert hit a three-run homer to left as Kansas City took a 6-3 lead.

Royals righthander Jakob Junis held the Twins to two earned runs over the first six innings. Scott Barlow entered for the seventh inning, and the Twins made their move. Kepler and Jorge Polanco began the inning with singles, then both moved up a base on a wild pitch. Nelson Cruz worked the count full before poking a Barlow pitch just past first baseman Cuthbert into right for a two-run single to get the Twins with 6-5.

He wasn’t going for a big swing with the count full — just looking for a hit. “That’s what he does on a pretty regular basis for us,” Baldelli said. “But he’s the kind of guy that can shorten up at times and do different things.”

Sano led off the eighth with his blast, and the Twins were on their way to their 16th comeback win of the season.

“We needed this win today and just get back to the way of playing we did a couple of weeks ago,” Rosario said. “Everybody was supportive of each other in the dugout, energetic. We stayed together and got the win.”