That was rain that fell steadily from the sky Thursday night at Yankee Stadium, but it might as well have been champagne as the Yankees stopped their three-game losing streak with a 4-1 win over the Red Sox and clinched their first postseason berth since 2012.

One more win in the three-game series that begins Friday night in Baltimore, or one loss by the Astros in their three-game series against the Diamondbacks, would clinch the first wild card and ensure that Tuesday night's American League wild-card playoff game is played at Yankee Stadium.

Carlos Beltran, Greg Bird and Rob Refsnyder homered for the Yankees, who had eight hits to back CC Sabathia (6-10), Adam Warren and Dellin Betances.

One night after Yankees ace Masahiro Tanaka was cuffed around for four runs by the Red Sox, Sabathia, who has excelled since coming off the disabled list on Sept. 9 after a knee problem, provided the first solid start of the series for the Yankees. He allowed one run and six hits in five innings.

Warren deserved half the decision for backing up Sabathia with three scoreless innings in which he allowed two baserunners. Betances got the save with a 1-2-3 ninth, striking out Josh Rutledge for the final out.

The clinching came more as a sigh of relief. There was no dogpile on the mound, just the usual postgame handshake line followed by a change of wardrobe on the field as the Yankees donned their postseason hats.

The clinching victory also marked the 10,000th win in club history. Describing the return to the playoffs in the first season without retired captain Derek Jeter, manager Joe Girardi said, "It's extremely gratifying with what we went through this year. These guys did it with heart and hard work. We had injuries and age, but they always fought back.

"The Yankees have always had great players. Derek Jeter was great for a long time and meant a lot to the franchise. We'll never forget what Derek did for the organization, but you have to move on."

The game began in a soaking drizzle that ebbed gradually as the game went on. Under the soggy conditions, it didn't figure fly balls would carry, but Beltran led off the second inning by launching a full-count fastball from lefthander Rich Hill (2-1) to rightfield for his 19th home run.

Hill, who pitched for the Yankees last season and for the Ducks this year, allowed a one-out walk to John Ryan Murphy and a two-out walk to Didi Gregorius before allowing an RBI single by No. 9 hitter Brendan Ryan for a 2-0 lead.

Sabathia gave up singles by Deven Marrero and Sandy Leon to begin the fifth. Rutledge popped up a bunt attempt, but Mookie Betts -- who had six hits, including three homers, and four RBIs in the first three games of the series -- singled to trim the Yankees' lead to 2-1.

Jackie Bradley Jr.'s groundout moved the runners to second and third, and Sabathia intentionally walked Xander Bogaerts to load the bases and set up a lefty vs. lefty confrontation with Travis Shaw. He flied out to center to end the threat and Sabathia's night after 96 pitches.

Jean Machi allowed Bird's one-out homer to rightfield -- his 11th of the season -- in the seventh for a 3-1 lead. In the eighth, Refsnyder hit Heath Hembree's first pitch over the fence in left-center for a 4-1 cushion.