New York’s Brendan Ryan scored the tiebreaking run in the ninth inning on a wild pitch by Jim Johnson after the Yankees blew a four-run lead before beating the Orioles 6-5 on Thursday.
Mark Reynolds and Curtis Granderson homered for the Yankees, who remained one game behind Tampa Bay for the second AL wild-card.
New York led 5-1 before Nick Markakis hit a solo shot in the seventh and Danny Valencia homered with two on against David Robertson in the eighth.
However, the Yankees bounced right back in the ninth with an unearned run against Johnson (3-8).
Mariano Rivera (6-2) got straight three outs in the bottom half and was given credit for the win by the official scorer because Robertson was ineffective in the eighth.
The start was delayed by rain for 1 hour, 18 minutes.
Elsewhere, Tampa Bay’s Wil Myers hit a tiebreaking double in the eighth inning to lift the Rays to a much-needed 4-3 win over Boston.
Cleveland also kept up in the wild-card race by routing the Chicago White Sox, while Oakland widened their lead in the AL West division by defeating Minnesota.
In the National League, Pittsburgh drew level with St Louis atop the Central division by downing the Chicago Cubs while the Cardinals were beaten by Milwaukee.
The Los Angeles Dodgers moved the brink of sealing the NL West title by edging San Francisco in 10 innings.
Tampa Bay’s Myers came up with the key hit to drive in Evan Longoria, who had also doubled off Rubby De La Rosa (0-1).
The result trimmed Boston’s lead in the AL East to a still comfortable 8-1/2 games.
The Red Sox got two men on base in the ninth with one out, but a line out and a pop out ended it.
Oakland moved 3-1/2 games clear of idle Texas atop the AL West by beating Minnesota 8-2.
Athletics pitcher A.J. Griffin (14-9) struck out eight and walked just one batter in seven innings to win his fourth straight start.
One team with few anxieties about their playoff hopes are the Los Angeles Dodgers, who stretched their lead in the NL West to 12-1/2 games by beating San Francisco 3-2.
The combined number of their wins and/or Arizona losses required to confirm the division title is now down to five.
Carl Crawford opened the 10th with a single off Jeremy Affeldt (1-5) and was advanced to second on a sacrifice before Adrian Gonzalez singled him home for the winning run.
There is nothing to separate Pittsburgh and St Louis atop the NL Central after the Pirates beat the Chicago Cubs 3-1.
Jeff Locke (10-5) struck out five and gave up only three hits and one walk in seven innings to steer the Pirates to a fourth-straight win. It was his first victory in nearly two months.
Meanwhile the Cardinals suffered a 5-3 defeat at the hands of Milwaukee, ending a run of five consecutive wins.
Brewers pitcher Tyler Thornburg (2-1), making his eighth career start, gave up three hits in six innings.
Sean Halton, who had three RBIs, hit a two-run homer in the fourth to put Milwaukee up 4-0.
Atlanta retained their big lead in the NL East by beating Miami 6-1, with Freddy Garcia earning his first victory since joining the Braves last month.
Washington’s Ryan Zimmerman, Adam LaRoche and Wilson Ramos all homered off Aaron Harang in his Mets debut as the Nationals beat New York 7-2.
Los Angeles’ Garrett Richards pitched 6 2/3 innings for his third straight win, steering the Angels to a 4-3 win over Toronto.