The Yankees fell a half-game behind idle Toronto and Boston atop the AL wild-card standings. New York had won three in a row.
"We've had a lot that have stung a lot at different times throughout the course of the year," Yankees manager Aaron Boone said. "This certainly falls into that category, but we have to get over it. We have too important of a game tomorrow."
Working on a wet night, Holmes was one strike away from his first career save when his high and outside fastball got past catcher Gary Sánchez, allowing pinch-runner Kelvin Gutierrez to streak home from third base with two outs. Yankees closer Aroldis Chapman had pitched the previous three days.
"It's definitely not ideal, but we're all playing the same game in it and you have to learn how to adjust and make pitches and do your job," Holmes said of the conditions.
Ryan Mountcastle homered for Baltimore, which snapped a five-game skid and avoided its 100th loss of the season. The Orioles improved to 12-22 in one-run games.
"We haven't caught a ton of breaks, and we feel like we got one tonight," Baltimore manager Brandon Hyde said.
Jahmai Jones, pinch-running for automatic runner Austin Wynns, moved to third on Richie Martin's leadoff bunt single against Wandy Peralta (5-4) in the 10th. After Cedric Mullins walked and Mountcastle struck out, Hays grounded a single to left over a drawn-in infield to win it.
Hays homered twice Wednesday night in the Orioles' 4-3 loss to the Yankees.
"We're playing against a team that's very, very talented and has high expectations, so for us to play back-to-back games playing toe-to-toe with these guys here for the last two nights, I'm very proud of that," Hyde said.
Cole Sulser (5-4) pitched two scoreless innings for Baltimore. Sulser and three other relievers combined for 5 1/3 scoreless innings.
Jordan Montgomery, who gave up a career-high seven runs in his last outing Friday against the New York Mets, was far crisper against the Orioles. He struck out a career-high 12, recorded multiple strikeouts in each of the first five innings, and allowed one run on six hits in 5 2/3 innings.
It was the 15th time this season a Yankee recorded at least 10 strikeouts, breaking the franchise record of 14 first set in 1963 and matched in 1998.
Joey Gallo hit his 35th homer of the season, and 10th since a July 29 trade from Texas, with one out in the second. After consecutive walks, Gio Urshela doubled to right to make it 2-0.
That was all the Yankees mustered against Chris Ellis, who allowed two runs on three hits and four walks in 4 2/3 innings. He struck out three.
"It's frustrating because we just weren't able to add on at all today," Boone said. "I thought we swung the bats well in the first half of the game and didn't have a lot to show for a lot of hard outs."
Mountcastle's drive, a leadoff shot in the sixth, was his 29th of the year to set an Orioles rookie record. Cal Ripken Jr. hit 28 homers in 1982.
Yankees: 2B DJ LeMahieu was out of the lineup. "He's fine, but I just felt like he needed a day today," Boone said. ... RHP Jonathan Loáisiga (shoulder strain) is expected to begin throwing again Friday.
Orioles: Hyde said 1B Trey Mancini (right oblique/abdomen) and C Pedro Severino (upper leg/groin discomfort) remain day to day. Both were out of the lineup for the second consecutive game. ... Baltimore claimed RHP Brooks Kriske off waivers from the Yankees and optioned him to Triple-A Norfolk. To make room on the 40-man roster, the Orioles transferred RHP Jorge López (ankle sprain) to the 60-day injured list. ... Jones was optioned to Norfolk after the game.
Yankees: RHP Corey Kluber (4-3, 4.02 ERA), a two-time Cy Young winner with Cleveland, faces the Indians for the first time on his career as New York returns home to open a three-game series.
Orioles: LHP Keegan Akin (2-9, 6.83) draws the start as Baltimore visits Boston to begin a six-game road trip.
Austin Hays hits walk-off single in 10th vs. Yanks
Austin Hays gets a single through the infield to score the game-winning run in the bottom of the 10th inning for the Orioles.