Brendan Ryan scored the tiebreaking run in the ninth on a wild pitch by Jim Johnson.
Baltimore is 4-4 on their current homestand and are now 1 1/2 games behind the Yanks in the AL Wild Card race.
The Tampa Bay Rays won to move 2 1/2 games ahead of the O’s.
“This is where everybody steps up their game – or we go home,” said Orioles second baseman Brian Roberts. “That is kind of the bottom line.”
After beating New York in the first game of the four-game series on Monday, Baltimore needed to win just one of the next three contests to take the season series for the first time since 1997.
Instead, the Yankees escaped with a 10-9 edge this year.