NEW YORK >> Matt Wieters homered from both sides of the plate, Kevin Gausman gave Baltimore a clutch pitching performance and the Orioles snagged a playoff spot on the final day of the regular season by beating the New York Yankees 5-2 Sunday.
Baltimore will play at AL East rival Toronto in the wild-card game Tuesday night for a chance to face AL West champion Texas in a best-of-five Division Series.
Zach Britton got five outs and finished perfect in 48 save chances this year with a 0.54 ERA. Wieters had four RBIs and Gausman (9-12) was charged with two runs in 7 1/3 innings as the Orioles closed with their seventh victory in nine games to reach the postseason for the third time in five years.
Seeking their first World Series championship since 1983, the Orioles (89-73) barely celebrated on the field after Britton struck out Brett Gardner to end it. Several players hugged each other behind the mound, but others simply walked out of the dugout and formed the customary handshake line.
Back in their clubhouse, however, manager Buck Showalter and the Orioles broke into a raucous party complete with spraying beer and champagne.
In his final game before retiring, New York slugger Mark Teixeira went 0 for 3 and showed off his Gold Glove form with a couple of slick plays at first base. Honored during a 12-minute ceremony and feted with several gifts before the game, he was removed with one out in the top of the seventh inning so he could soak up the cheers while he walked off the field, fully composed as he hugged his teammates one at a time.
"Mentally and emotionally, I kind of prepared for it," Teixeira said. "It wasn't as weird as I thought it would be."
Teixeira tipped his cap to the crowd of 33,277 as it offered a standing ovation. He patted his chest with his glove and said, "Thank you."
And with that, one of baseball's most prolific switch-hitters said goodbye to the game.
"I couldn't have asked for anything more but a win," Teixeira said. "I got a chance to say goodbye, which was very important."
Baltimore squandered a three-run lead Saturday in a 7-3 loss to New York that made their playoff prospects more complicated. But the Orioles got help that night when Detroit and Seattle were beaten, so they knew when they arrived at Yankee Stadium on Sunday that all they needed was a win to get in.
Jonathan Schoop reached on a pop-fly double leading off the third and put Baltimore ahead when he scored on J.J. Hardy's sacrifice fly.
In the fourth, Wieters was batting left-handed when he hit a two-run homer into the second deck in right field on a 3-0 pitch from Luis Cessa (4-4). That came one batter after Mark Trumbo reached on an infield single when Teixeira failed to scoop third baseman Ronald Torreyes' short-hop throw.
Manny Machado singled in the sixth and Wieters, batting right-handed, greeted lefty reliever Tommy Layne with another two-run drive just inside the left-field foul pole.
Brian McCann went deep for the fourth-place Yankees (84-78), reaching 20 homers for the ninth consecutive season and 10th time overall.
Didi Gregorius had an RBI single off Britton with two outs in the eighth before first baseman Chris Davis grabbed Aaron Hicks' sharp grounder with two on to end the inning.
The Orioles went 9-10 against the Blue Jays (89-73) this season. They were 4-5 in Toronto, but took two of three crucial games there just last week.
It was the first time Wieters homered from both sides of the plate in a major league game. He became the first Orioles player to do it since Hall of Fame second baseman Roberto Alomar against Cleveland on July 25, 1996. ... Wieters has seven career multihomer games, three this season.
Yankees 2B Starlin Castro and 3B Chase Headley were the regulars who sat out the season finale.
Orioles: Chris Tillman (16-6, 3.77 ERA) figures to start the wild-card game.
Yankees: Play their season opener next year April 2 at Tampa Bay.