BOSTON — Sonny Gray wasn’t a victim of foul play Sunday. He was a victim of foul balls.

The Red Sox shortened the day for the Yankees right hander by driving his pitch count up to 106 and getting him out of the game after five innings. He exited the 5-1 loss trailing 2-1 after Boston fouled off a dozen of his two-strike pitches.

“I thought I made some good pitches with two strikes,” Gray said. “They just fouled [them off]. I don’t know how many foul balls they had, but it seemed like every time I made a quality pitch, they put together quality at-bats and fouled it off. They put a lot of good at-bats together and they made it pretty difficult.”

Gray’s line wasn’t terrible, although he dealt with traffic on the basepaths in every inning. He gave up seven hits and two walks and — for the first time in 117 appearances, including 115 starts — didn’t strike out a single batter.

“They have a deep lineup and they have a good lineup. There’s not a lot of strikeout guys in their lineup,” manager Joe Girardi said. “They fouled a lot off today. That’s how they got into long counts. It didn’t seem like [Gray] was really behind, but they kept fouling pitches off and would get to better counts.”

Gray’s big miscue was a pitch too high in the zone to Jackie Bradley Jr. with two on and two out in the second inning that resulted in a two-run triple. Gray called it Boston’s “one big hit” against him.

Since Gray (7-8, 3.38) joined the Yankees in a trade with Oakland at the July 31 non-waiver trade deadline, he has pitched reasonably well but with little support. In four starts, the former A’s ace is 1-3 with a 3.13 ERA and has allowed two or fewer runs in each. The Yankees have scored only five runs in the 23 innings in which he was in the game.

advertisement | advertise on newsday

“Again, we didn’t get the distance we want out of him, but he kept it within reach,” Girardi said. “They just really made him work.”

Asked about the best way to combat a team that is driving his pitch count up, Gray said, “You just keep attacking.

“You have to continue to try to throw quality pitches and hope that instead of foul balls, they put them in play or get some soft contact. It’s just today it was a lot of foul balls.”