Adam Jones delivered his first home run in nearly three weeks, a shot that lifted the Orioles to a 2-1 win and pushed them a half-game ahead of the Yankees in the American League East. Closer Jim Johnson, who blew a save in the series opener, came out and retired the final three batters to seal the win.

The victory -- a thunderclap turnaround for a team that had trailed since the second inning -- was stunning on a number of levels. Rivera had converted 41 straight save opportunities at home, a streak that took him all the way back to September 2010, before Jones took him deep to left field.

"It's off the greatest closer in the history of the game. I'll always remember it," said Jones, who was elected as an All-Star starter for the AL on Saturday. "You've got to win, and we haven't been playing that well. We need to tighten up. We need to clean it up around here."

New York (48-40) and Baltimore (49-40) have played extremely close this season, but the Orioles own a 7-5 advantage and won't see the Yankees again until the end of August. Baltimore had just three hits in the first seven innings Sunday, and only two runners were able to reach scoring position.

The Orioles, down to their last two outs in the ninth, appeared poised to fall to a series sweep and their fourth straight loss by one run. And there was something else at stake: The Orioles hadn't lost a 1-0 game since getting shut out by this very team, the Yankees, on Sept. 20, 2008.

The ninth inning, in this case, brought real drama. Nick Markakis drilled a long foul that narrowly missed being a home run off Rivera, and then he singled with one out. That brought Jones to the plate, and the All-Star outfielder drilled a shot over the left-field fence to give the Orioles their first lead.

Baltimore manager Buck Showalter credited the Yankees' relievers -- namely setup man David Robertson and Rivera -- but said that the victory felt good for a number of reasons.

"Any time you're sitting there with Robertson and Rivera, you don't like your chances," he said "But there was a good vibe in the dugout. The guys were grinding. And it's tough. Very challenging conditions. ... That's why if you can achieve things, it's so gratifying, because it's so hard to do. These are the days where you can challenge yourself to be a little different than the common athlete."

The Yankees, so accustomed to Rivera's dominance, fell to 40-2 when leading after eight innings. The Orioles improved to 3-29 when trailing at that point of the game. For Rivera, it was just his second blown save of the season and the first homer he's allowed at home since August 2011.

"I've faced him for years now," said Markakis. "He's still got late cut on the ball. He puts the ball where he wants it. His velocity might be down, but that's expected from a guy who's been around as long as he has. He's still the best closer in the game. You've just got to go up there and battle."

Prior to the Jones homer, Baltimore had searched to find a spark. Hiroki Kuroda left after seven shutout innings, handing the ball to Robertson and Rivera. Two of Baltimore's first three hits were doubles -- one by Matt Wieters and one by Markakis -- but both runners wound up stranded at second base.

The Yankees, despite the loss, peppered starter Jason Hammel in the early innings. Zoilo Almonte drew a leadoff walk and moved to third base on a hit in the second inning, and shortstop Eduardo Nunez sent him home with the game's first run on a sacrifice fly to medium-depth left field.

Hammel would come out after the fifth inning, and Baltimore's bullpen held the game close. Third baseman Manny Machado made a sensational play to close out the sixth inning. The All-Star third baseman bobbled the ball, drifted into foul territory and made an incredible throw to nab the runner.

"When you can shake hands with the beer man in the front row after you get through with a play, you know it's pretty challenging," said Showalter. "Or the Oriole fan that was there."

Showalter and Jones both took time to laud Markakis for his grind-it-out approach at the plate. Markakis, who narrowly missed election to the All-Star Game, admitted after the game that he thought his foul ball might stay fair, but he said that he couldn't afford to dwell on the near miss.

"Those are situations you're going to deal with. The game's not over," he said. "Down 0-2, I'm just looking to make contact there. I wasn't trying to do too much. Like I've said, I just thought he was trying to get it out there a little further, and it caught more plate. ... That's the good thing about this team: You get on base, and you've got those guys hitting behind you. Good things happen."

"He's one of the guys that I've seen bring it for six years, every single day," added Jones. "He's one of the guys that I'd give up my spot for. He's one of the guys that I've seen year-in, year-out earn it. I'm not saying other people haven't, but he's one guy that earns it. He brings it every day. He can flat-out hit. He can flat-out play the game, plays a great right field. He was the catalyst of it today."

The victory also meant a chance for Johnson to make good. The right-hander leads the league in saves (30) and games finished (38), but he's also blown six saves this season. Two of Johnson's blown saves have come against New York, lending more impact to Sunday's save.

Eleven of the 12 games played in this season series have been decided by three runs or fewer, and Baltimore and New York have played five one-run games in 2013.

Showalter said he was thrilled to see his team's resilience on Sunday, and he was especially happy for his closer.

"You don't wallow around in, 'What happened yesterday means it's going to happen tonight,'" he said. "I'm so proud of Jimmy. I told you many times, there's nobody here who wants the Orioles to win more than him and I'd ask him to do anything and he'd do it. It means a lot to a lot of these guys. We've got some guys who have been with the Orioles a long time, and it means something to them to win."