– Glen Perkins squatted in front of the mound and dropped his head as Rajai Davis pumped a fist while circling the bases.

A little more than two months ago, Perkins finished the All-Star Game. Friday, his hit-me-hard slider to Davis in the eighth inning became a two-run homer that sent the Twins to a 6-4 loss to Detroit. And Perkins looked exasperated as Davis touched them all.

“It’s beyond frustrating,” Perkins said.

Perkins had a hand in the Tigers’ final four runs, giving up a two-run double to Victor Martinez in the seventh as he tried, but failed, to put out a fire. Then Nick Castellanos led off the eighth with a double before Davis’ two-out gutbuster.

“I’m at a loss for words,” said Perkins, who battled neck and back injuries over the past month and lost his closing job to Kevin Jepsen. “It’s disappointing. This whole second half for me has been torture. If I pitch the way I know I can — the way I have — we probably clinch a playoff spot. We’d be in a heck of a lot better position than we are now.”

With their second loss in a row, the Twins have only nine games to beat out Houston and the Los Angeles Angels for the second wild-card spot. And the remarkable thing about Friday was that they held a 4-1 lead after six innings despite having only one hit.

With Mike Pelfrey pulled following a tense fifth inning in which he only gave up one run, Blaine Boyer pitched a scoreless sixth, but Casey Fien was charged with three runs in the seventh thanks in part to Perkins’ outing.

Fien gave up a one-out single to Dixon Machado, then needed 14 pitches to retire Davis on a fly ball. But the Twins couldn’t get the third out. Anthony Gose walked and Ian Kinsler launched a ball that hopped over the fence for an RBI ground-rule double.

The Twins called for Perkins, who issued a four-pitch walk to Tigers star Miguel Cabrera to fill first. Martinez then lined a 1-0 pitch to left-center for a tying two-run double.

“We had it set up fairly well heading into the last nine outs of the game,” Twins manager Paul Molitor said. ‘‘We just couldn’t find a way to finish.”

If the game went only six innings, it would have been the Eddie Rosario show. The rookie got his 16th outfield assist, hit his league-leading 15th triple and scored on a sacrifice fly — to second base. He is the first player to have at least 15 triples and 15 outfield assists in a season since Philadelphia’s Johnny Callison in 1965.

Three innings after throwing out J.D. Martinez trying to advance from first to third, Rosario came up with the bases loaded in the fifth, after Miguel Sano and Trevor Plouffe walked and Torii Hunter reached on an error.

Matt Boyd still hadn’t given up a hit at that point, but he left a 1-0 pitch belt-high and over the middle of the plate, and Rosario launched it to right-center. The ball deflected off a fan, and the bases emptied as Rosario ran to third. A review proved fan interference, but umpires ruled Rosario would have had a three-run triple anyway.

After Kurt Suzuki popped out, Eduardo Escobar hit a pop-up Kinsler caught just a few feet on the outfield grass. Rosario took off for home, and a surprised Kinsler threw short, and the ball skipped by catcher James McCann for a 4-0 Twins lead.

The Twins managed only one more hit, the seventh time this year they were held to two or fewer hits. Yes, they all are losses.

“It’s a hard one to swallow,” Molitor said. “The last few weeks we have had some tough losses. You just have to move on.”