CLEVELAND (AP) -- Pinch-runner Eduard Nunez scored from third base on a wild pitch and Torii Hunter hit a sacrifice fly in the ninth inning to give Minnesota a 4-2 victory over the Cleveland Indians on Thursday night, moving the Twins a little closer to an AL wild-card spot.

Facing a crushing loss, the Twins scored a run in the eighth to tie it and then two unearned runs in the ninth off Cody Allen (2-5) to pull within one game of idle Houston for the second wild-card berth with three games left.

Trevor Plouffe reached on second baseman Jose Ramirez's throwing error with one out in the ninth. Nunez, running for Plouffe, then raced to third on Eddie Rosario's single to right before Allen bounced a 2-2 pitch to Hunter in the dirt. Hunter followed with a fly to deep right, bringing in Rosario.

More from FoxSports

Glenn Perkins (3-5) pitched a 1-2-3 eighth and Kevin Jepsen worked the ninth for 15th save.

Down 2-1 and in danger of losing a game they couldn't afford to, the Twins tied in the eighth against reliever Bryan Shaw on Eduardo Escobar's hit-and-run RBI double.

Roberto Perez's two-run homer off Twins rookie Tyler Duffey in the seventh inning had given Cleveland a 2-1 lead.

Duffey took a four-hit shutout into the seventh when Abraham Almonte singled with one out before Perez drove a 3-1 pitch over the wall in center for his seventh homer. As the shot cleared the wall, Twins second baseman Brian Dozier put his hands over his head in shock and disappointment.

But the Twins weren't done and Ramirez, who had angered them with some post-home run theatrics on Wednesday night, made the crucial error that ignited their rally.

Cleveland's Trevor Bauer, making his first start since Sept. 13, allowed just one run and two hits -- two doubles in the fourth -- and got a no-decision. The quirky right-hander, who flew a drone above the field before the game, was demoted to the bullpen last month but made only one appearance in relief.

There were no issues between the teams, one night after Ramirez flipped his bat toward Minnesota's dugout after hitting a three-run homer.

Minnesota manager Paul Molitor hinted before the game that there would be no immediate retaliation by saying, "We're going to prioritize winning."

And that's what the Twins did as Ramirez didn't even see an inside pitch while going 0 for 4.

Plouffe's two-out, ground-rule RBI double in the fourth gave the Twins a 1-0 lead.

TRAINER'S ROOM

Indians: OF Michael Brantley plans to begin a two-week recovery program on his right shoulder with the hope he'll be able to avoid surgery. Brantley was shut down Wednesday for the remainder of the season with an injury sustained last week while trying to make a diving catch.

"Nobody ever wants to go under the knife," said Brantley, who received a cortisone shot. "As it stands right now, we're heading in the right direction."