The Yankee Stadium crowd, which had begun to tentatively believe in Gray after a recent pair of solid outings, responded as it had during many of Gray’s outings in his brief Yankees tenure, with grumbles, boos and catcalls. They only grew louder when Gray allowed another run in the third inning. He ended up lasting five innings, allowing five runs on nine hits and three walks. He had two strikeouts.

The game ended in a 10-5 win for the Athletics, who had just been swept in a three-game series against the Houston Astros in which they were outscored by 24-5. The Yankees, who had just won the first two of three games against the Red Sox and joined them atop the American League East, have now lost two consecutive games for the first time since April 10.

Gray was coming off back-to-back starts in which he limited the Astros and the Cleveland Indians each to two runs over six innings. But he regressed to the pitcher he had been earlier in the season — nibbling around the plate, unable to put hitters away on two-strike counts.

Although his fastball was reaching 94 miles per hour, the Athletics feasted on it. Both Davis and Chapman hit fastballs that were left out over the plate.

“Except for the homers, I thought I threw the ball O.K.,” said Gray, who is 2-3 with a 6.39 earned run average. “I just couldn’t put it together. I felt like my stuff was pretty good, but at the end of the day they put five runs across the board in five innings. When you do that, it’s going to be tough to win those games.”