The losses all hurt at this time of year, but, to be fair, it is tough to hammer a team that wins three of four in a series.

Still, the Yankees’ 4-2 loss to the last-place Rays at Yankee Stadium on Sunday, which ended their winning streak at seven games, nonetheless had the feel of a tremendous failure.

And certainly an opportunity lost, especially with a schedule that will bump up dramatically in difficulty Monday night when the NL West-leading Dodgers come to town.

“Every loss hurts just because it’s a day you don’t make up any ground, or you lose ground,” Joe Girardi said. “Every loss at this point stings just because of how few games are left.”

The Yankees and Tigers, both 76-66, are two games behind the Orioles and Blue Jays, both 78-64, who own the two American League wild cards. Said Girardi, “I think there’s more parity now in the game than there’s ever been.”

advertisement | advertise on newsday

The Yankees, watched in person Sunday by managing general partner Hal Steinbrenner, trail the AL East-leading Red Sox by four games.

“We’re playing great baseball. You’re not going to win every game that you play,” said Chase Headley, whose 14th homer pulled the Yankees within 2-1 in the fifth inning. “We didn’t give them the game, we didn’t kick the ball around, we didn’t walk a bunch of guys. They just beat us today . . . I love the way we’re playing, I love the way guys are competing . . . Of course it would have been great to keep it going, but we just have to start a new one tomorrow.”

Yankees bats went surprisingly silent against Rays righthander Matt Andriese (7-7, 4.46), who had allowed seven earned runs in each of his previous two starts. He gave up one run, six hits and no walks in five innings Sunday.

The Rays (60-82) damaged rookie Luis Cessa (4-1) with the long ball. He allowed four runs and five hits, including three home runs, in 5 2⁄3 innings in his fifth big-league start.

Those homers, a two-run blast in the second inning by Corey Dickerson and solo shots in the sixth by Logan Forsythe and Brad Miller that made it 4-1, made it 13 allowed by Cessa in 47 2⁄3 innings.

Yankees videos

“It’s a lot, it’s something we have to work on,” Girardi said. “But overall, he’s made a ton of progress this year.”

Said Cessa: “At this level, you can’t miss your spots. When you miss your spots, they usually hit them out.”

Rays manager Kevin Cash, who likely did not want to tempt fate by letting Andriese go much longer, called on former Yankees righthander Chase Whitley to start the sixth.

Whitley, who had Tommy John surgery on May 19, 2015, and had last appeared in a big-league game May 14, 2015, as a Yankee (against the Rays at Tropicana Field), retired the Yankees in order on 10 pitches.

After Whitley allowed an unearned run in the seventh that made it 4-2, Brad Boxberger pitched a perfect eighth. Alex Colome struck out two in a perfect ninth for his 32nd save.

advertisement | advertise on newsday

After Brett Gardner’s two-out RBI single in the seventh off Whitley, which came after third baseman Evan Longoria booted a two-out grounder by Starlin Castro, Jacoby Ellsbury flied out to left with runners on second and third.

“We dug ourselves a pretty good hole that we’ve been fighting all year to get out of,” Headley said. “Especially this last month and a half, we’ve played much better. We’re confident we can go out and beat anybody the way we’re playing right now.”