BALTIMORE — It would have been a gift run, but one Joe Girardi believed the run-starved Yankees deserved. And with Masahiro Tanaka and Kevin Gausman throwing zeroes, it was one his offensively bereft club needed.

And so a non-balk call by third-base umpire Chris Guccione with a runner on third in the fourth inning incensed Girardi, who soon was ejected. Starlin Castro would be stranded at third, and there were few scoring chances by either club after that until the 10th inning.

That’s when the Orioles finally won it on Pedro Alvarez’s sacrifice fly off Andrew Miller, handing the Yankees a dispiriting 1-0 loss Thursday night that closed a dispiriting 2-7 trip. “It’s really disappointing,” Girardi said. “But we start a long homestand and we have to make up some ground.”

That will not be easy. Two first-place teams, the Red Sox and White Sox, sandwich the defending World Series champion Royals in a 10-game homestand that starts Friday night.

advertisement | advertise on newsday

The loss was the 19th time in 26 games that the Yankees (9-17) have scored three or fewer runs (they’ve gone 3-16 in those games) and the 14th time they have scored two or fewer (0-14).

“It’s kind of been the story of the season,” Mark Teixeira said. “We just haven’t hit. It’s not rocket science. We just need to execute better.”

Against righthander Johnny Barbato, Hyun Soo Kim opened the 10th with an infield single and went to third on Jonathan Schoop’s single to left. As pinch runner Nolan Reimold replaced Kim, in came the lefthanded Miller to face the lefthanded-hitting Alvarez, who lifted a 0-and-1 slider to medium center. Reimold easily beat Jacoby Ellsbury’s weak, off-line throw home.

“I have to make a better pitch,” said Miller, unnecessarily trying to take the bullet for the loss. “I’m ahead 0-1.”

With two outs in the ninth and Castro on second, Brian McCann swung through a 3-and-1 pitch and Matt Wieters picked off Castro. “That’s a play that can’t happen there,” Castro said.

Yankees videos

Defense saved the Yankees in the bottom of the inning. With one out and pinch runner Joey Rickard on first against Dellin Betances, Wieters skied one deep to right. Dustin Ackley made a leaping catch against the wall, robbing Wieters of an extra-base hit, and when Rickard wandered all the way to second, thinking the ball had hit the wall, he was doubled off first.

McCann walked to start the 10th but pinch runner Brett Gardner was stranded as Zach Britton struck out Teixeira, Carlos Beltran and Ackley.

Tanaka turned in by far his best start of the season, not to mention the best by any Yankees starter in 2016. He followed up the Yankees’ 7-0 win Wednesday night by allowing five hits and a walk with seven strikeouts in eight innings and lowered his ERA to 2.29. “Maso was great,’’ Teixeira said. “Unfortunately, Gausman was just as good.”

Gausman went eight shutout innings and lowered his ERA to 1.42. He allowed three hits and did not walk a batter.

“Obviously, we’re not at our best right now [offensively],” Tanaka said through his translator. “But my job is to go out and try to put up zeroes.”

advertisement | advertise on newsday

Castro doubled into the leftfield corner on the first pitch of the fourth and went to third on McCann’s fly to center. Teixeira followed with a sharp grounder to first, with Castro holding.

With Beltran at the plate, Girardi walked to the third-base end of the dugout and began jawing with Guccione, arguing that Gausman had balked. The two yelled and gestured at each other throughout the at-bat, which ended with Beltran popping out.

As the Orioles came off the field, the shouting continued and Guccione, responsible for Girardi’s first ejection as Yankees manager in 2008, tossed him. After an animated on-field argument, Girardi began walking away from Guccione, who cupped one hand over his mouth to yell something more at Girardi. Girardi stopped, spun back and verbally sparred some more.

Girardi’s contention was that Gausman never came set in the stretch. “He’s balking,’’ he said. “They can say he’s not trying to deceive the runner, [but] he’s not stopping . . . [Guccione] threw me out when I was coming out to get an explanation. That bothered me.”

advertisement | advertise on newsday