BALTIMORE — Two out of three ain’t bad — unless you’re looking to make some headway in the crowded AL playoff race.

The Baltimore Orioles sputtered in the clutch Sunday, and the resulting 5-2 loss to the New York Yankees ruined their bid for a three-game sweep.

Coming off an 8-0 win on Friday night and a 2-0 victory Saturday, the Orioles missed a chance to sustain the momentum before hitting the road.

“We’re trying to win games. You beat them twice and you’re trying to beat them a third time,” manager Buck Showalter said. “We just didn’t have much offensively.”

The Orioles stranded nine and went 0 for 10 with runners in scoring position.

After falling behind 4-0 in the fourth inning, Baltimore closed to 4-2 before wasting an opportunity to complete the comeback in the fifth.

Adam Jones led off with a single and scored on a double by Pedro Alvarez. Luis Severino (2-8) replaced starter Michael Pineda and struck out Manny Machado before issuing two straight walks to load the bases. Steve Pearce struck out and Matt Wieters chopped a grounder to second base to end the threat.

Baltimore got only one more hit the rest of the way.

Before this series, the Orioles had lost five of seven. So while failing to complete the sweep wasn’t ideal, at least Baltimore could take consolation in being in position to do so.

“I mean, I’m trying to keep a positive mind frame,” first baseman Chris Davis said. “We won the series and we’ll move forward.”

Baltimore is tied with Detroit for the second AL wild-card slot, but the loss dropped the Orioles three games out of first place in the AL East.

After being shut out three consecutive times by the Orioles over a seven-day span, the Yankees promptly put an end to the streak with a three-run first inning.

Wade Miley (8-12) walked the first two batters and struck out the next two before Chase Headley hit an RBI single. A wild pitch and a two-run single by Austin Romine followed.

Headley singled home a run in the fourth, and Pearce hit a run-scoring grounder in the bottom half.

Brett Gardner made it 5-2 with a sacrifice fly in the ninth.

The victory was huge for the Yankees, who came to town after winning four straight series.

“You can’t afford to lose three in a row to these guys,” manager Joe Girardi said. “We know they play really well in this building. We lost a tough one (Saturday) night. To be able to bounce back is important. It keeps us alive.”

Indeed, the young, retooled Yankees remain a part of the playoff picture, trailing Baltimore and Detroit by 3 1/2 games for the final wild card.

Severino (2-8) pitched two strong innings of relief and Dellin Betances, the fifth New York reliever, got four outs for his eighth save.

TRAINER’S ROOM

Yankees: SS Didi Gregorius was held out of the starting lineup after absorbing some bumps and bruises during the series. “His arm is sore where he’s been hit the past few days,” Girardi said. . 1B Mark Teixeira doesn’t usually play in day games after playing the previous night, and thus was given Sunday off. Commenting on the ice pack Teixeira had on his neck before the game, Girardi said, “He deals with his neck, he deals with his knee. It’s not what you want, but it’s the reality.”

Orioles: RHP Chris Tillman (shoulder) threw off a mound and remains on course to come off the disabled list on Sept. 11.

UP NEXT

Yankees: RHP Masahiro Tanaka (11-4, 3.12 ERA) opens a three-game series against visiting Toronto on Monday. New York is 3-9 against the Blue Jays this season, losing all four series.

Orioles: RHP Ubaldo Jimenez (5-11, 6.46) starts Monday in the opener of a three-game series at Tampa Bay. Baltimore is 29-37 on the road, 3-3 at Tampa Bay.