Matthew Boyd on Friday was in the middle of being a pain in the Twins’ sides for the second time in less than a week, but things changed in the seventh inning.

Tyler Austin blasted a 458-foot home run off Boyd. Jake Cave dumped a single to center. Johnny Field was hit by a pitch. Tigers manager Ron Gardenhire went to the mound and took the lefthander out of the game, replacing him with righthander Louis Coleman.

Detroit does not have a lefthanded reliever. That made Paul Molitor’s decision to pinch hit Joe Mauer for Ehire Adrianza a no-brainer.

“You get a chance to use one of the best players in the last decade and a half in the game in a big situation,” Molitor said. “It is kind of a nice card to have in the deck.”

And Mauer has been an ace with runners on base, leading the majors with a .429 batting average with runners in scoring position.

He worked the count full, and Coleman gave Mauer a fastball as hittable as can be — right down the heart of the plate. Mauer pounded it into the seats above the right-field scoreboard for a three-run homer that propelled the Twins to a 5-4 win over the Tigers. The pinch-hit home run was just the second in Mauer’s career, the other coming May 25, 2009, when he connected off of Boston’s Jonathan Papelbon in the Metrodome.

“It’s awesome,” Mauer said. “I mean, just walking to the plate in that situation, tonight’s crowd was awesome, great energy and I kind of had to step out a couple times just to take a couple deep breaths just to control the emotions a little bit. After it hit the seats, that was pretty awesome.”

The announced crowd of 26,605 had to be nudged awake after Boyd no-hit the Twins for four innings. But after Mauer’s blast they were on their feet and roaring. And starting pitcher Kyle Gibson nudged Mauer out of the dugout for a curtain call.

“That’s about as professional an at-bat as you’re going to see,” Gibson said. “That’s Joe Mauer right there. He’s a guy that gets a tough pitcher’s pitch on 3-1, doesn’t panic and gets the pitch he needs to hit and just put one of the best swings you’ve ever seen. That’s him.”

The Twins were up 5-3 then. When the game reached the ninth, Molitor looked into his closerless bullpen and selected Matt Magill. He gave up an RBI single to Ronny Rodriguez and was a strike away against Victor Reyes from ending the game but walked Reyes at the end of a 13-pitch at-bat to put two runners on. Taylor Rogers came on and got Jeimer Candelario to ground out for his first major league save.

Boyd no-hit the Twins for the last five innings of his outing against them on Sunday. Add nine more at the start Friday and he retired 27 Twins without giving up a hit.

Gibson (7-9), who dueled with Boyd, got Detroit to hit into four double plays over the first five innings. But the Tigers scored twice in the fourth on a wild pitch and Victor Martinez’s RBI single, then added another run in the sixth on Nick Castellanos’ RBI single.

Eddie Rosario homered off Boyd in the sixth to get the Twins within 3-1. The Twins knocked Boyd out of the game in the seventh — then got a matchup in their favor with No. 7 at the dish.

“The things that he does, I don’t think we’re really thinking homer,” Molitor said. “But he showed patience, waited until he got a good pitch that he can handle and it turned out to be the difference.”