Updated

Twice the Baltimore Orioles provided Jason Hammel with a two-run cushion. Each time, he gave it back.

Throw in a costly error by first baseman Chris Davis and a timely home run by New York's Mark Teixiera, and the explanation for the Orioles' 8-5 loss to the New York Yankees on Monday night becomes crystal clear.

Hammel hadn't given up more than two runs in any of his first six starts, so after Baltimore jumped to a 2-0 lead in the first inning the Orioles had every reason to be confident.

New York overcame that deficit and also bounced back against Hammel after Baltimore went ahead 5-3 in the fifth.

"Honestly, we should have won the ballgame," Hammel said. "I let them back into the game twice."

It wasn't entirely his fault. He left in the sixth after loading the bases and with Baltimore up by two runs. Luis Ayala got Raul Ibanez to hit a potential double-play grounder to first, but Davis left the ball get past him, allowing two runs to score.

"I just wasn't ready to make the catch," Davis said. "Tried to make the throw before I had the ball."

It's not a play normally associated with a first-place team.

"That's the thing we've been doing the last few weeks really well is making sure we clean everything up and play good defense behind our pitching staff," Davis said.

Teixeira hit a tiebreaking two-run homer in the seventh inning and Curtis Granderson also connected for the Yankees, who got three hits from Alex Rodriguez.

It was the fourth win in five games for New York, now 4-0 at Camden Yards this season.

Teixeira had five hits in his previous 33 at-bats and was hitting .220 when he drove a 1-2 pitch from Ayala (1-1) into the right-field seats.

The slugger, who has been battling a cough for a month, said, "I'm just trying to grind through it. In this game, you're always playing through something."

Teixeira also doubled in the ninth and scored on a fly ball by Eric Chavez.

New York shortstop Derek Jeter got his 3,143rd hit, a single up the middle in the third inning, to move out of a tie with Robin Yount into sole possession of 16th place on the career list.

J.J. Hardy homered and had three RBIs for the Orioles, who dropped into a tie with Tampa Bay atop the AL East. After going hitless in his first big league game Sunday, Baltimore leadoff hitter Xavier Avery doubled, tripled, scored twice and drove in a run.

"X had a good night. I was real proud of him," manager Buck Showalter said.

Yankees starter Ivan Nova allowed five runs and seven hits in 5 1-3 innings before leaving with a bruised and sprained right foot. The right-hander took a line drive off the top of the same foot in the third inning, courtesy of Nick Markakis, but shook it off.

David Phelps (1-1) entered in the sixth and got three outs for his first big league win. Rafael Soriano, the sixth New York pitcher, worked the ninth for his second save.

Hammel gave up five runs, four earned, in five-plus innings. He was seeking to become the first pitcher in Orioles history to begin a season with seven straight starts of allowing two or fewer runs.

After a 14-minute rain delay, Baltimore jumped to a 2-0 first-inning lead. Avery led off with a double and received hearty congratulations from Jeter at second base after his first major league hit. Hardy followed with an RBI single and Adam Jones doubled in a run.

The Yankees pulled even in the fourth when Nick Swisher hit a two-run double following singles by Rodriguez and Robinson Cano.

In the fifth, Granderson launched a 2-1 pitch over the right-field scoreboard, the 61st homer in the 21-year history of Camden Yards to land on Eutaw Street.

Baltimore went up 5-3 in the bottom half. Avery tripled in a run and Hardy followed with a drive into the left-field seats.

NOTES: Cano went 2 for 5 and is batting .469 (15 for 32) in his last eight games. ... Davis went 0 for 4 and is mired in a 3-for-28 skid. ... One day after making his first major league start since 2010, New York LHP Andy Pettitte said, "I feel good. I really do."... New York opponents have scored within the first two innings in 28 of 35 games this season. ... Orioles INF Zelous Wheeler, who was designated for assignment on Friday, cleared waivers and was outrighted to Double-A Bowie.