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 taking a 4-2 loss Sunday afternoon to the last-place Rays, which ended a seven-game winning streak, nonetheless brought the feel of a tremendous fail.

And certainly an opportunity lost, especially with a schedule that bumps 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 (76-66) are, along with the Tigers, two games behind the Orioles and Blue Jays, who have the same record at 78-64, for the AL wild card.

The Bombers, watched in person Sunday by managing general partner Hal Steinbrenner, who was among the 33,087 at the Stadium, 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, who hit his 14th homer of the season in the fifth inning to pull the Yankees within 2-1. “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, who came in 6-7 with a 4.58 ERA and having allowed seven earned runs in each of his last two starts. Sunday, he allowed one run and six hits in five innings.

The Rays (60-82) damaged rookie Luis Cessa (4-1) with the long ball. The 24-year-old allowed four runs and five hits, including three homers, in his fifth big-league start.

Those blasts, a two-run shot 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 homers allowed in 13 appearances (five starts) for Cessa.

“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, likely not wanting to tempt fate by letting Andriese go much longer, called on former Yankees righty Chase Whitley to start the sixth.

Whitley, who had Tommy John surgery May 19, 2015 and 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, righty Brad Boxberger came on and pitched a perfect eighth. Righthander Alex Colome struck out two of three in the ninth for his 32nd save.

After Brett Gardner’s two-out, RBI single in the seventh off Whitley, which came after third baseman Evan Longoria booted a grounder by Starlin Castro to keep the inning alive, the Yankees did not get another baserunner.

“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.”