BALTIMORE -- Pitching well as a rookie in the big leagues is difficult enough. Dominating the New York Yankees is something else entirely.

After seven games with the Baltimore Orioles, Wei-Yin Chen appears comfortable doing both.

Chen pitched seven innings of four-hit ball, Adam Jones homered and the Orioles beat CC Sabathia and the Yankees 5-2 Tuesday night.

J.J. Hardy drove in two runs for Baltimore, which earned a split of the two-game series and improved to 1-4 at home against New York.

Chen (4-0) allowed two runs, struck out four and walked two in a masterful performance. The 26-year-old Taiwan native took a shutout into the seventh inning against the Yankees' formidable lineup -- and made it look easy.

"He located really well," Orioles manager Buck Showalter said. "Command of the fastball was really key tonight. Once he showed them that he could do that on both sides of the plate, the whole world opened up for him."

Chen's first outing against the Yankees came on April 10, when he allowed a homer to the first batter he faced and ended up giving up two runs and seven hits in 5 2/3 innings.

He was far better this time.

"The first time, the debut I was so nervous," Chen said through an interpreter. "This time, I was just like I've had this experience already so everything was fine to me."

Chen retired 10 straight before Robinson Cano's leadoff double in the seventh.

Two outs later, Curtis Granderson hit his 13th home run, an opposite-field drive that barely cleared the 7-foot wall in left -- a fan wearing a Yankees jacket knocked his glove into the mitt of rookie outfielder Xavier Avery.

"I don't know if it was somebody in midnight blue or black and orange there," Showalter said. "I've got an educated guess."

It was only the third homer yielded by Chen in 44 innings this year, and it got the Yankees to 4-2.

Chen came out to the mound for the top of the eighth but was pulled by Showalter when the Yankees sent up a pinch hitter. That enabled the Orioles fans in the crowd of 24,055 to give the left-hander a hearty standing ovation.

Pedro Strop got Cano to hit into an inning-ending double play in the eighth, and Jim Johnson got three outs for his 12th save in 12 tries.

Chen outpitched Sabathia (5-1), who came in 16-2 lifetime against the Orioles, including 10-1 at Camden Yards. The husky right-hander was seeking to go 6-0 for the first time in his career, but instead absorbed his first loss in Baltimore since April 2009.

Jones gave the credit to Chen.

"It started with our pitching," he said. "Chen halted that lineup and gave us an opportunity."

Sabathia gave up four runs, eight hits and a season-high four walks in six innings. He had pitched eight innings in each of his previous four starts.

"The four walks killed me," he said. "That's a really good team over there. It was a battle."

New York is 5-3 against the Orioles, and no win has been easy.

"They're a much improved team," manager Joe Girardi said. "Their pitching has improved dramatically. That's the big difference."

Jones gave Baltimore a 1-0 lead in the second inning with his team-high 11th home run, the first surrendered by Sabathia since April 29. Eight of Jones' homers have either tied the game or put the Orioles in front.

Baltimore loaded the bases with no outs in the third but got only one run, on a 6-4-3 double-play grounder by Hardy. Hardy didn't receive credit for an RBI on that one, but in the fifth inning he lined a run-scoring double to left following a walk to Avery.

In the sixth, Chen showed his deftness in the field by stabbing a liner by Nick Swisher at eye level for the final out.

Baltimore went up 4-0 in the bottom half during an inning in which only one ball got out of the infield. Bill Hall walked and Steve Tolleson singled to right before infield hits by Robert Andino and Hardy produced a run. Hardy's RBI single behind second base handcuffed Cano, whose high throw to shortstop Derek Jeter was too late to force Andino.

Granderson's homer halved the lead, but the Orioles made it 5-2 in the bottom of the seventh when Jones singled, stole second, advanced on a grounder and scored on a passed ball.

Game notes:

Baltimore went 4-5 on a homestand against Texas, Tampa Bay and New York. ... The Yankees placed RHP David Robertson (strained left oblique) on the 15-day DL and recalled RHP Cody Eppley. ... Orioles RHP Tommy Hunter takes the mound for the Orioles on Wednesday for the opener of a two-game series in Kansas City. The Yankees head to Toronto for a two-game swing beginning Wednesday night. ... Doug O'Neill, trainer of Kentucky Derby winner I'll Have Another, threw out the ceremonial first pitch. He's in town for the Preakness, which will be run Saturday.