NEW YORK -- Sonny Gray's home debut for the New York Yankees was a stress-free night.
The latest outing by struggling closer Aroldis Chapman was not, and also created a possible injury concern.
Gray pitched effectively into the seventh inning, but Chapman allowed a two-run homer to rookie Amed Rosario in the ninth as the Yankees held on for a 5-4 victory over the New York Mets on Tuesday night at Yankee Stadium.
Using a deceptive delivery, Gray (7-7) took a shutout into the seventh before giving up Dominic Smith's first career home run, a two-run shot. He allowed two runs and five hits in six-plus innings before exiting to a nice hand from the sellout crowd.
"It was a fun game overall and anytime you come away with the win it makes it that much better," Gray said.
It wasn't as enjoyable for Chapman, whose ERA is 13.51 in his last three appearances.
Two nights after allowing a game-tying homer on a 103 mph fastball to Boston rookie Rafael Devers, Chapman allowed an infield hit and Rosario's second career homer on a 2-1 slider.
He recorded two ground ball outs to notch his 16th save in 20 chances, but after the game said he felt some tightness in his hamstring after running off the mound to cover first base on the game's final out.
Chapman also said through a translator that "it's nothing to worry about." The Yankees said no tests are planned and manager Joe Girardi did not even know which hamstring it was.
Before Chapman's latest adventure, Gray delivered a third straight effective showing as a Yankee.
Gray allowed two earned runs or fewer for the ninth straight start. It is the longest streak in the American League and the second-longest in the majors, one behind Philadelphia's Aaron Nola.
"The delivery's so deliberate and then all of sudden there's action," Mets manager Terry Collins said. "He's really a tough guy to get too much timing on."
Jacoby Ellsbury hit a two-run homer in the fourth and Gary Sanchez hit a solo homer off Mets starter Jacob deGrom in the sixth. Aaron Hicks had an RBI single in the third, and Sanchez lifted a sacrifice fly in the eighth as the Yankees remained 4 1/2 games behind the Boston Red Sox in the American League East.
Before Tuesday, the Yankees did not score when Gray was pitching in his first two starts for them. Prior to Hicks' hit, the Yankees were 0-for-15 with runners in scoring position when Gray was on the mound.
DeGrom (13-6) made his 100th career start. He allowed five runs and nine hits in 7 1/3 innings against the opponent he made his major league debut against on May 15, 2014, at Citi Field.
"Three balls hit hard, the rest were just out of reach of somebody," deGrom said. "They did a good job of hitting my mistakes and hitting some good pitches They just did a good job and they beat me tonight."
He showed little effect from getting hit in the triceps Thursday at Philadelphia but allowed five earned runs for the first time since June 6.
After the Yankees took a 3-0 lead through four innings, Sanchez hit a 1-0 changeup into the first row of the left-center bleachers. It was Sanchez's 21st homer and fifth in 11 games.
Sanchez hit a sacrifice fly after Smith ended Gray's night with a two-run homer into the left field seats.
Tommy Kahnle pitched a scoreless seventh, and Dellin Betances struck out Michael Conforto with Yoenis Cespedes on second to end a scoreless eighth before Chapman nearly endured his fifth blown save.
NOTES: The Mets placed LHP Seth Lugo (right shoulder impingement) on the 10-day disabled list before the game. RHP Robert Gsellman (strained left hamstring) was activated from the DL, and will start Wednesday against the Yankees at Citi Field in place of Lugo. ... Yankees 1B Greg Bird (bruised right ankle) will begin a rehab assignment with Triple-A Scranton/Wilkes-Barre on Wednesday. ... Mets RHP Noah Syndergaard (strained lat muscle) threw 20 pitches in a bullpen session, marking the first time he threw of a mound since going on the DL. ... Yankees LHP CC Sabathia (right knee inflammation) could be activated from the disabled list this weekend in Boston if his second bullpen session Wednesday goes well.