The Yankees are back in the postseason, though not the way they wanted.
Aaron Hicks doubled home the winning run in the 11th inning, and New York clinched an AL wild card with a 3-2 win over the Baltimore Orioles on Saturday.
Rookie manager Aaron Boone will lead the Yankees into the winner-take-all Oct. 3 wild-card game, most likely against Oakland. The Yankees began the day 1½ games ahead of the Athletics for home-field advantage and are 53-27 at home this season.
Hicks and Luke Voit homered in the second inning, but the Orioles tied the score with runs in the third and the fifth off Lance Lynn.
Tampa Bay, third in the wild-card chase, lost at Toronto as the ninth inning was about to start in the Bronx. The Yankees finally broke through after Didi Gregorius singled off Paul Fry (0-1) starting the 11th.
Giancarlo Stanton struck out. Hicks fouled a pitch off his left foot, then took a ball. He lined a low, inside slider down the left-field line, and Gregorius sped home, sliding in headfirst ahead of shortstop Jonathan Villar's relay throw. Gregorius spread his arms wide, and the Yankees poured out of the dugout to celebrate.
New York sprinted to a 54-27 record at this season's halfway point and was ahead of Boston by percentage points in the quest for its first AL East title since 2012, but the Yankees slowed in the second half as Aaron Judge, Gary Sanchez, Gregorius and Aroldis Chapman got hurt. The Red Sox clinched their third straight division crown by beating New York on Thursday.
Still, at 95-59 the Yankees matched their most wins since 2012 and equaled their season high of 36 games over .500. They will make their 54th postseason appearance - 21 more than any other team.
Boone replaced Joe Girardi after the Yankees, led by a rebuilt roster filled with youth, reached last year's AL Championship Series but lost to Houston in seven games.
New York's bullpen, which has struggled at times, showed its strength.
Chapman, in his second outing since returning from the disabled list, struck out two in a perfect seventh inning - his earliest appearance in a game since Aug. 24 last year. Dellin Betances fanned three straight batters in the eighth, and Zach Britton struck out two more in a one-hit ninth.
Jonathan Holder allowed DJ Stewart's double on his first pitch in the 10th but escaped. Baltimore had second and third with no outs when Adam Jones grounded to third with the infield in. After an intentional walk, Chris Davis lined out to a diving Voit at first and Breyvic Valera popped out.
Tommy Kahnle (2-0) pitched a one-hit 11th.
Baltimore dropped to 44-110, one shy of the franchise record for losses set by the 1939 St. Louis Browns. The Orioles entered 60½ games out of first place.
Hicks and Voit connected in the second off David Hess, raising the Yankees' team-record home run total to 251. Voit's drive hit the Toyota sign above New York's bullpen in right-center and gave him 11 homers and 25 RBIs in 32 games since he was acquired from St. Louis.
Cedric Mullins' tapper in front of the plate drove in a run in the third, and DJ Stevens singled in the tying run in the fifth.
Baltimore's Steve Wilkerson was thrown out at the plate twice, by Gleyber Torres after the second baseman retrieved Sanchez's errant throw and by Judge on Caleb Joseph's single to right in the fifth. Wilkerson threw out Torres trying to score from third on Andrew McCutchen's seventh-inning grounder to third.
Lynn struggled and failed to pitch a 1-2-3 inning. He allowed two runs - one earned - in five innings but got a key out in the fifth when Adam Jones bounced into an inning-ending forceout with the bases loaded. Jones is 2 for 15 against Lynn.
Hess gave up two runs in five innings and is 1-9 in his last 15 starts.
A day after the Yankees said the struggling Sanchez would be their postseason starter, he allowed his major league-leading 15th passed ball - he tied for the high last year with 16. He also made his sixth error.
Davis struck out three times, raising his total to seven in two games and 192 this season. He is hitting .168.
Miguel Andujar hit his 42nd double, two shy of Joe DiMaggio's Yankees rookie record in 1936.
Baltimore assured itself the top pick in next year's amateur draft with Friday's loss, which meant the Orioles will at best be tied with Kansas City for most defeats in the major leagues. The Orioles had a poorer record in 2017, which would be the tiebreaker. Baltimore's only previous No. 1 overall selection was used for right-hander Ben McDonald in 1989.
Orioles: RHP Andrew Cashner remains bothered by pain in his left knee. ... RHP Hunter Harvey is to have his sore elbow examined Monday, according to manager Buck Showalter.
LHP J.A. Happ (6-0, 2.39 ERA with the Yankees; 16-6, 3.62 overall) starts Sunday's home regular-season finale and is lined up to start the wild-card game. He allowed one run and two hits over six innings to win at Oakland on Sept. 4. RHP Alex Cobb (5-15) starts for the Orioles.