BALTIMORE — The proclamations a little more than a month ago from the owner, general manager and manager were met mostly with derision.

When the Yankees sold off Aroldis Chapman, Andrew Miller and Carlos Beltran before the Aug. 1 trade deadline, the conventional wisdom was that the organization, muddling along at 52-52, had hoisted the white flag over the 2016 season.

But Hal Steinbrenner, Brian Cashman and Joe Girardi insisted the deals not only made the Yankees better for years, but also didn’t necessarily disqualify them from playoff contention this season.

It was the latter that elicited widespread laughter.

But a funny thing happened on the way to their surrendering of the season.

The Yankees, buoyed by an infusion of youth to the roster and a solid performance from a pitching staff that at times has had a drawn-out-of-a-hat look to it, went 17-11 in August to put themselves in the thick of the AL wild-card race as the calendar turned to September.

“We never felt our season was over when those moves were made,” Chase Headley said.

And, indeed, with 30 games to go, the Bombers trail the Orioles, whom they play this weekend in Baltimore starting Friday night, and Tigers by 21/2 games for the second wild-card spot.

“There’s a toughness in there,” Girardi said. “These guys really want it.”

The Yankees have won their last four series, taking two of three from the Mariners, Orioles and Royals in that stretch.

The spurt allowed the Yankees to leapfrog two teams that had been ahead of them in that chase – the Mariners and Royals. The Royals had won seven straight series, and 17 of their last 21 games, before dropping two of three to the Yankees.

“This is the best time of the year,” Brian McCann said. “The guys that have come up really made impacts on this team. It’s been impressive to watch and they’re a big reason we’re back in it.”

McCann lost his starting catcher job to one of those players, Gary Sanchez.

In 24 games since becoming an everyday player, Sanchez has a .389/.458/.832 slash line, with 11 homers and 21 RBI. Of his 37 hits, 20 have gone for extra bases.

But it hasn’t just been Sanchez, or Tyler Austin and Aaron Judge, both of whom have cooled after hot starts. Didi Gregorius and Starlin Castro have been terrific and Jacoby Ellsbury and Brett Gardner have had their moments.

Masahiro Tanaka and CC Sabathia have churned out consistent starts to anchor a rotation suddenly featuring rookies Chad Green and Luis Cessa. The bullpen is a somewhat odd mix that includes veterans Adam Warren and Tyler Clippard – trade deadline acquisitions made by Cashman as a sign that he wasn’t quitting on the season – and a pair of 31-year-old journeymen, Blake Parker and Tommy Layne. There’s also rookie Ben Heller, a perhaps resurgent Chasen Shreve and, of course, the pen’s stalwart, closer Dellin Betances.

“We always thought we were better than we played,” Headley said. “Even once those guys got traded, I remember (third-base coach) Rob Thomson saying, ‘Hey, that doesn’t change anything we’re doing in here, all that matters is what we believe.’ We believe we’re good enough to compete and beat anybody that we’re playing. We’ve made up a decent amount of ground but we’ve still got a ways to go.”

Warren, part of the trade last offseason with the Cubs that netted Starlin Castro and who returned in the Chapman deal, said a nothing-to-lose attitude permeates the clubhouse.

“We can see it right there in front of us now, so there’s a lot more motivation for that, but I think we still have to keep the same mindset,” he said. “We’ve been loose, playing like we have nothing to lose and that’s worked for us. Just go out there free and easy and see what happens.”