BALTIMORE — The Yankees spent an impressive August putting themselves very much in contention for the second AL wild card.

Two games into September, they’re quickly taking themselves out of it.

Wasting a mostly terrific outing by CC Sabathia, the Yankees were shut out for a second straight game, this time by Kevin Gausman and three relievers, as they lost to the Orioles, 2-0, Saturday night in front of 30,855 at Camden Yards.

The Yankees (69-65), who came in having won four straight series to climb within 2 ½ games of the Orioles for that last playoff spot, are 4 1⁄2 behind Baltimore (74-61) with 28 games to go. They were held to four hits Saturday night after managing only two Friday night and were shut out for the fourth time in the last 12 games.

“It’s not frustrating,’’ Sabathia (8-12) said after allowing two runs, one earned, in six innings. “It’s baseball. But we need wins and we just need to do a better job.”

“It’s tough,’’ Joe Girardi said of the two-game slump. “You don’t ever want to go through this during the course of the season, so [Sunday’s] game is probably the most important game of the year.

advertisement | advertise on newsday

“I think you do feel it more just because you’re running out of time. That’s why I think [Sunday is] extremely important. We have to find a way to score runs.”

Michael Pineda will face Orioles lefthander Wade Miley on Sunday as the Yankees try to salvage a game in the series, and Girardi hopes the inconsistent Pineda will be at his best. “Really important,’’ he said, “because if you’re inconsistent against this team, you know what happens. He’s got to be on his game.”

Remember Dallas Keuchel, the Astros lefthander who tormented the Yankees all of last season, including the AL wild-card game?

Gausman is this year’s Keuchel.

In five starts against the Yankees this season, the righthander is 2-1 with a 0.80 ERA, having allowed three runs in 33 2⁄3 innings. Gausman (7-10), who is 5-9 with a 4.41 ERA against everyone else, allowed two hits, walked two and struck out eight in six innings.

Yankees videos

Gausman struck out the first four hitters he faced, including the side on 15 pitches in the first, before Starlin Castro’s one-out single in the second.

Mychal Givens pitched a one-hit seventh, Brad Brach threw a one-hit eighth and Zach Britton improved to 40-for-40 in save chances and lowered his ERA to 0.65 with a perfect ninth.

Sabathia came in 8-11 with a 4.31 ERA but was 3-7 with a 6.06 ERA in his previous 13 outings. For the second straight week, he was on his game against the Orioles, who came in with an MLB-best 213 homers. He had lost to Gausman, 5-0, last Sunday as Gausman struck out nine in seven innings and Sabathia was charged with three runs in 6 2⁄3 innings after exiting with the score 1-0.

Sabathia said his numbers this time around suggested a better outing than his stuff warranted. “I didn’t have much,’’ he said. “Just trying to make pitches when I had to and was able to do that for the most part, but it was a struggle today.”

The Yankees had their best scoring chance against Gausman in the fourth, a 30-pitch inning that left him at 80 through four.

advertisement | advertise on newsday

With one out, Jacoby Ellsbury walked, Gary Sanchez reached on an infield single and Didi Gregorius was hit by a pitch to load the bases, but Castro struck out and Brian McCann flied to left for the third out.

The Orioles took the lead in the bottom of the inning. Mark Trumbo led off by lining a double to left, and one out later, Chris Davis hit a broken-bat single to right. Aaron Judge booted the ball for an error that allowed Trumbo to score. “Took my eye off it,” Judge said.

It was the first run allowed by Sabathia in three starts at Camden Yards this season, albeit unearned.

Adam Jones tagged the lefthander for an earned run with two outs in the fifth, ripping a belt-high 1-and-1 fastball to left for his 25th homer. It improved Jones to 21-for-70 with five home runs against Sabathia.

J.J. Hardy led off the seventh against Adam Warren with a double to left and pinch hitter Michael Bourn beat out a high chopper to the pitcher for an infield single, putting runners at the corners. The Orioles, however, ran themselves out the inning. When Caleb Joseph hit a grounder to third, Hardy took off for home and was caught in a 1-2-5 rundown for the first out. Warren struck out Jones and walked Steve Pearce to load the bases before striking out Manny Machado.