DETROIT — Tyler Duffey knew that he needed a clean fourth inning Wednesday night.

Not only didn’t he get one, he couldn’t even get three outs.

The Minnesota Twins had just scored five runs in the top of the fourth to take a 5-2 lead over the Detroit Tigers. If Duffey could shut them down in the bottom of the inning, the Twins would have regained the momentum that saw them beat Detroit 8-1 on Tuesday.

“Our guys scored enough runs in the top of the inning to win the game,” Duffey said. “I just wanted to protect that.”

Instead, Justin Upton walked and scored on Andrew Romine’s RBI single before Kinsler and Maybin hit back-to-back two-out triples to tie the game.

“I gave it right back,” Duffey said. “When you are facing that offense, when you miss, they don’t. They got rolling, and I couldn’t stop it.”

Twins manager Paul Molitor knew his team was in trouble after the walk to Upton. The Tigers’ left fielder only has a .296 on-base percentage this year, with 40 walks against 165 strikeouts.

“When you get a big inning and get a lead, you want your pitcher to go out there and shut them down,” Molitor said. “That walk was a bad sign, but he still had two outs and could have gotten off the field if he gets Kinsler or Maybin.”

By the end of the inning, the Tigers led 6-5, and although Minnesota tied the game in the fifth, Miguel Cabrera’s seventh-inning homer led Detroit to a crucial 9-6 win.

The Tigers trail the Blue Jays by one game for the second AL wild card, with the Yankees and Mariners another game back.

Cabrera said that, along with his offense, his role as a veteran is to keep the younger players from losing confidence by reading social media.

“We hear a lot of bad things about how we’re not going to make it,” Cabrera said. “I’ve been here a lot of years and I’ve been through this, but we’ve got a lot of new guys who think about it and read stuff. I tell them not to worry.

“This is fun. We’ve got a chance to make the playoffs. That’s what you play for.”

Ian Kinsler had four hits, finishing a homer short of the cycle, and drove in three runs while scoring two.

Brian Dozier and Kurt Suzuki homered for the Twins.

Shane Greene (5-4) got the win, while Ryan Pressly (6-7) took the loss after surrendering Cabrera’s homer.

Bruce Rondon pitched the eighth for Detroit, while Francisco Rodriguez put up a perfect ninth for his 42nd save.

After Anibal Sanchez struck out the side in the first, Kinsler and Cameron Maybin gave the Tigers the lead with back-to-back doubles in the bottom of the inning. Kinsler’s RBI single in the second doubled the lead.

Sanchez retired the first nine batters in order, but Dozier launched his first pitch of the fourth into the left-field stands for his 41st homer. The next three batters singled, with Kennys Vargas driving home Jorge Polanco to tie the game.

Suzuki then made it 5-2 with a homer down the left-field line, but the Tigers came back in the bottom of the inning.

After Kinsler and Maybin’s triples, J.T. Chargois replaced Duffey and allowed a tiebreaking single to Cabrera. Sanchez, though, couldn’t hold the lead. He walked Byron Buxton to start the fifth and Dozier followed with a double to make it 6-6.

Alex Wilson got out of the inning without further damage, and the two bullpens were able to settle the game down until Cabrera’s homer off Pressly with one out in the seventh.

The Tigers added two more runs in the eighth on Kinsler’s second RBI single and a wild pitch.

TRAINER’S ROOM

Twins: 3B Miguel Sano missed his second straight game with back stiffness. He’s expected back for Minnesota’s weekend series against the Mets. . Suzuki left the game in the eighth injury with a lacerated chin after being hit in the mask by a foul tip. Molitor said he’s day-to-day, but might see action at DH while the injury heals.

Tigers: RHP Jordan Zimmermann threw an 80-pitch simulated game Wednesday afternoon in an attempt to fix his mechanics and get back into the rotation. Due to assorted injuries, Zimmermann has only started twice since June and didn’t escape the second inning either time. … 3B Nick Castellanos (broken hand) batted once against Zimmermann before taking himself out of the lineup. He hopes to be back before the end of the regular season.

ODD DEFENSIVE LINEUP

Zimmermann, who mostly faced September call-ups in his simulated game, didn’t get a lot of help from his defense. Instead of one of baseball’s best double-play combinations in Ian Kinsler and Jose Iglesias, Zimmermann had his fellow pitchers backing him up. Rookie of the Year favorite Michael Fulmer made a nice running catch on a pop up into shallow right, but Mike Pelfrey, Mark Lowe and Justin Verlander weren’t impressive as infielders.

OLYMPIC WEEK CONTINUES

For the third straight day, an Olympic medalist from Rio threw out the first pitch. On Wednesday, it was New Zealand’s Nick Willis, who won the bronze medal in the 1,500-meter run. Willis spent his college career at the University of Michigan, and still lives in Ann Arbor.

UP NEXT

The teams conclude their four-game series with the Tigers’ Mike Pelfrey (4-9, 4.76) facing the Twins’ Hector Santiago (11-8, 4.75). Pelfrey hasn’t pitched in a big-league game since July 30 due to a back injury, and is expected to be on a 60-pitch limit.