New York Yankees shortstop Ronald Torreyes reacts after he hits...

New York Yankees shortstop Ronald Torreyes reacts after he hits the game-winning RBI single against the Texas Rangers during the tenth inning in a baseball game at Yankee Stadium on Friday, June 23, 2017. Credit: Kathleen Malone-Van Dyke

All along the Yankees have said all would be OK with Masahiro Tanaka, their unquestioned ace during the previous three seasons who to this point of 2017 had been hands-down their worst starter.

Facing countryman Yu Darvish, a rival when the pair were aces for their respective clubs in Japan, just might have snapped Tanaka out of his funk.

He didn’t factor in the decision but at the very least had a co-starring role Friday night as Ronald Torreyes’ two-out RBI single in the 10th inning gave the Yankees a 2-1 victory over the Rangers at the Stadium.

“I was super-happy to get the hit,” Torreyes said through his translator. “But without Tanaka, we don’t have a chance. He was excellent tonight.”

After the game, the Yankees made many of their fans super-happy by designating Chris Carter for assignment. Carter had struck out for the third time in the game moments before Torreyes delivered. Tyler Austin was promoted from Triple-A Scranton/Wilkes-Barre.

Tanaka, who came in 5-7 with a 6.34 ERA, including 0-6 with a 8.91 ERA and 15 homers allowed in his previous seven starts, was terrific. He allowed three hits and two walks and struck out nine in eight scoreless innings in his best outing since a three-hitter at Fenway Park on April 27.

“Just because of the way I’ve been pitching, it does boost your confidence,” Tanaka said. “But now the game is over and you prepare for the next one.”

After Brett Gardner tied it at 1-1 with his 14th home run, a one-out shot off Matt Bush in the ninth, and Chasen Shreve worked out of a bases-loaded, two-out jam in the 10th, Torreyes gave the Yankees only their second victory in the last 10 games.

The win kept the Yankees (40-31) in a virtual tie with Boston (41-32) for the AL East lead.

With Bush still pitching, Gary Sanchez singled with one out in the 10th and went to third on Didi Gregorius’ single to right-center. Carter heard loud boos as he walked to the dugout after striking out, but the 5-7 Torreyes, among the most popular players in the clubhouse, lined a single to center on a 1-and-0 pitch to end it. He knew it immediately, throwing up his arms as the ball headed for the outfield.

“He’s very valuable,” Joe Girardi said of Torreyes, who made two standout plays at third to help Tanaka, “because he can do so many things.”

Aroldis Chapman allowed an unearned run in the ninth. Elvis Andrus singled with one out, Chapman hit Nomar Mazara with a pitch and Andrus stole third on a 1-and-1 pitch to Adrian Beltre that was called a strike. Beltre struck out on a 102-mph fastball, but when the low pitch got away from Sanchez and went to the backstop for a passed ball, Andrus scored to make it 1-0.

Shreve inherited a two-on, one-out situation from Chad Green in the 10th. He struck out Joey Gallo, walked Shin-Soo Choo and got Andrus on a pop to second. “I’ve really been focusing on staying calm [in those situations],” Shreve said.

Darvish allowed two hits in seven scoreless innings, walking none and striking out 10. But for the Yankees, Tanaka was the story. “He went out,” Gardner said, “and showed tonight what he’s capable of doing.”

More Yankees headlines

Newsday LogoSUBSCRIBEUnlimited Digital AccessOnly 25¢for 5 months
ACT NOWSALE ENDS SOON | CANCEL ANYTIME