BALTIMORE - When Manny Machado's would-be home run was snagged by a leaping Alfonso Soriano in left field, it felt as if a standout defensive play would mark the unofficial end of the Baltimore Orioles' postseason run.
With 16 games to go, and more than one team to chase for a wild-card spot, the Orioles were fading fast amid a three-run deficit in the eighth inning against New York on Thursday night.
Until Danny Valencia, the club's hottest hitter, changed things with one mighty swing and tied the game with a three-run home run.
Baltimore's good vibes didn't even last an inning.
Jim Johnson came in and unraveled quickly, and a wild pitch with runners on second and third spelled the end for the Orioles. New York overcame Valencia's thrilling homer to beat Baltimore 6-5 in front of 24,659 at Camden Yards.
Johnson (3-8) gave up a single to Brendan Ryan to open the ninth, and committed a throwing error at second on Chris Stewart's sacrifice attempt. Curtis Granderson moved the runners over with a sac bunt, which brought up Alex Rodriguez.
Johnson uncorked a wild pitch and Ryan scored from third to give the Yankees a 6-5 lead.
Mariano Rivera, who was honored by the Orioles (77-69) in a pregame ceremony for his pending retirement, closed it out in the ninth and was given the win. Instead of his 44th save of the year, Rivera improved to 6-2.
Rivera's win came because David Robertson was ineffective in the eighth for the Yankees (79-68). Robertson allowed three runs and four hits in the eighth, courtesy of the Valencia homer.
Valencia's eighth home run of the year was part of a four-hit inning for the Orioles, and his gave him 23 hits in his last 42 at-bats. Adam Jones and Nick Markakis each singled with two outs before Valencia put one into the Baltimore bullpen on the first pitch he saw.
Baltimore trailed 5-1 in the seventh when Markakis went deep himself to lead off the inning for his 10th homer of the season. Yankees relievers Adam Warren and Cesar Cabral escaped trouble from there, but Robertson did not in the bottom half of the frame.
Neither did Johnson or the Orioles, however, in the ninth.
Baltimore trails both New York and Cleveland in the wild-card standings, and falls into a tie with Kansas City at 2 ½ games behind Tampa Bay. And the Orioles are 12-17 since Aug. 11 with the loss.
The Yankees jumped on Baltimore starter Wei-Yin Chen early and reached base eight times in their first 14 at-bats.
Vernon Wells had the bases loaded with no outs in the third and delivered a two-run single to left, giving New York a 4-0 lead. But Chen settled down after that and retired 13 in a row, until Curtis Granderson smacked a one-out homer in the seventh inning, onto the flag court in right field, that gave the Yanks a 5-1 lead.
The Orioles got on the board in the third on Manny Machado's RBI single to right that scored Matt Wieters, who singled and moved to second on a wild pitch. Machado later advanced to second on another wild pitch, but Yankees starter Phil Hughes struck out Chris Davis to end the inning.
The Yankees grabbed a 2-0 lead in the third on Mark Reynolds' two-run shot to left. It was Reynolds' 200th career home run, and 12th of the season. The former Orioles infielder hit 60 during his time in Baltimore, a time that ended with him helping the Orioles make the playoffs for the first time since 1997.
The chances of them going back are dwindling, however.