BALTIMORE — Just one more out Sunday afternoon, at a sticky, steamy Camden Yards, and Adam Warren would put himself in line for his fifth victory of 2015. With Orioles on first and second, and with the Yankees leading by two runs in the bottom of the fifth, here came Baltimore’s lefty-swinging Travis Snider, who had popped out twice — once to left field, once to third base — in his two prior encounters with Warren.

And here came Joe Girardi, signaling for southpaw Chasen Shreve and ensuring that Warren would leave town with a no-decision.

Shreve retired Snider on a foul pop to left field, and so began a Yankees bullpen relay that would lead the team to a much-needed 5-3 victory over Buck Showalter’s O’s, halting a three-game losing streak and avoiding a Baltimore sweep after a pair of ugly defeats.

Maybe Warren would have retired Snyder, too, and received the win for his efforts. But this was no time for sentiment, not with three rivals nipping at the Yankees’ heels atop the American League East. Girardi’s urgency set the tone on an appropriate day to do so.

“You don’t want to get swept,” Girardi said. “It’s a division opponent. We did not play well the first two days. We played much better today. We didn’t give them extra outs, and we won the game.”

They won the game thanks to backup catcher John Ryan Murphy, who broke a 3-3 tie in the top of the fifth with a two-out, two-run double off the glove of Orioles diving third baseman Manny Machado. And thanks to lefty relievers Shreve (whom the official scorer credited with the win) and Justin Wilson, who combined to pick up 10 outs, and Dellin Betances, who threw a scoreless ninth for his first save since Andrew Miller went on the disabled list.

Then again, this marked the Yankees’ first victory since Miller went down with an ailing left forearm. The Rays have won three straight games and the Blue Jays 11 straight, and the Orioles’ 9-4 thumping of the Yankees Saturday gave them a six-game winning streak. The Yankees needed this win to stay a percentage point ahead of Tampa Bay.

Friday’s score here was 11-3 in the home team’s favor, and perhaps the only upside of all that was the Yankees’ best relievers hadn’t pitched for two days. So when the Warren-Snyder matchup approached, Girardi had more than the need for a win in mind.

“I think it’s important,” Girardi said, “but the other thing is, these guys were rested. I haven’t always had that luxury with them.”

On the other side of the equation, Warren — still the obvious candidate to switch back to the bullpen upon Ivan Nova’s return from Tommy John surgery — had labored and competed through his work shift.

“I just thought that, hot day, you throw [92] pitches in less than five innings,” Girardi said. “If he had breezed through a bunch of innings and maybe it was in the sixth or seventh inning, it’s a different story. Just looking at the slider and some of his pitches, he’d gotten behind in some counts, I just thought it was time.

“The competitor in you wants to finish that and get deeper in the game, but it worked out for us,” Warren said. “I want to win a ballgame, so I’m not concerned with having wins under my name or whatnot. We win as a team. It worked out. No problem with it at all.”

Shreve pitched a 1-2-3 sixth, and when he walked Manny Machado to start the seventh, Girardi turned it over to Wilson, who began his day by striking out lefty-mashing pinch-hitter Delmon Young and picked up five more outs.

“It sucks we lost Andrew, but I’ve started [pitching] in, I guess, more meaningful innings,” Wilson said. “They’re all fun.”

Because Girardi deprioritized the game’s emotional component and didn’t allow his game strategy to be governed by an outdated statistic — in this case a win for his starting pitcher — the Yankees found their clubhouse to be a pretty fun place late Sunday afternoon.