In a game of dueling grand slams, of last at-bat comebacks and missed opportunities, the Twins pulled out a 7-6 victory on Sunday by doing nothing at all.

Which is exactly what the situation called for.

"We had several guys go out there and not swing," Twins manager Rocco Baldelli said proudly. "They did not offer at those pitches, and that takes discipline and toughness."

With two outs in the 13th inning of the longest game of the season, Joey Gallo took four consecutive balls from Rangers reliever Jonathan Hernández. Then Matt Wallner got behind 1-2, but watched three straight balls sink below the strike zone, loading the bases.

And Michael A. Taylor, with the Target Field shadow all but blinding him at the plate, watched — well, as much as he could — four more pitches from Hernández sail wide. Taylor's walk forced courtesy runner Carlos Correa in from third base, and the Twins, who trailed 5-0 after four innings, beat Texas for the third time in four games.

"The shadow was pretty tough. The ball was tough to pick up," said Taylor, who went 0-for-4 yet still scored two runs and drove in the winner. "I was taking the first pitch, because of what happened ahead of me. But at this level, you never know — guys can just all of a sudden throw three pitches right down the middle."

But Hernández didn't, and the Twins walked away with one of their more stirring victories of the season. And what great timing: the Guardians, who trail them by six games with five weeks to play, arrive Monday for a three-game showdown.

"We're in a good spot [with] a lot of confidence from a good series like this," Taylor said. "We're playing good baseball and we're heading in the right direction."

It didn't seem like it after J.P. Martínez hit his first career home run, a blast onto the plaza behind the right-field seats, in the second inning, and Jonah Heim connected on a grand slam to the first row in the same direction two innings later.

Both came off Bailey Ober, who has given up at least one home run in each of his eight starts since the All-Star break. He gave up five runs over four innings, and his post-All-Star ERA now stands at 5.85 — more than double his 2.61 mark before the break.

But Dallas Keuchel, who pitched six perfect innings one week earlier, this time shut down the Rangers without a run for five innings in relief of Ober, giving the Twins a chance to close that gap. Royce Lewis took advantage when the Twins loaded the bases in the sixth inning against Texas lefthander Jordan Montgomery. When Chris Stratton was summoned to face Lewis, the rookie was ready.

"I faced [Stratton] the other day, and he was throwing good sliders. I just knew I had to get out in front of it," Lewis said of the low slider that Stratton left over the middle. "I tried to elevate the ball and put it in the air. I was lucky enough to do that."

Still, the grand slam only closed the gap to 5-4, and the Twins couldn't dent it. When Rangers closer Aroldis Chapman took the mound in the ninth, the Twins seemed headed to a split of the four games.

Not so fast.

Taylor drew a one-out walk, taking a 99.9-mph inside fastball to start the rally. Chapman then stepped off the rubber one time too many, a clock-rule violation that moved Taylor to second. And Donovan Solano followed by belting a 100-mph fastball into center field, tying the score.

"I've faced him before and hit him very good, but without any results," Solano said. "Today, I'm glad I had a result in that situation."

Neither team could score in the 10th or 11th innings, even with a runner on second to start. The Rangers finally scored in the 12th on a sacrifice fly, but the Twins responded, with Taylor moving to third on a wild pitch and scoring on Jorge Polanco's hot grounder to third.

An inning later, Taylor was critical again — by not swinging.

The perfect way to prepare for a series with their chief pursuer, Baldelli said.

"Our team is tough. We kept working, never relented at any point," Baldelli said. "I was so impressed with our group. … That's how you fight and win a ballgame."