The wild card-contending Yankees dropped to 7-9 against the Orioles this year. Baltimore is 1-18 against AL East-leading Tampa Bay.
New York wasted leads of 4-1, 5-2 en 7-4 and lost for the sixth time in eight games following its first 13-game winning streak since 1961.
Sánchez hit a slam in the second inning, and his homer in the sixth off Marcos Diplan (1-0) gave the Yankees a 7-4 lead and earned the catcher a brief curtain call. But the reception from the crowd changed when Andrew Heaney (8-9) allowed four runs in the seventh.
Jorge Mateo hit a single to cap a 12-pitch at-bat for a 7-all tie and Kelvin Gutierrez followed with a go-ahead single.
After getting the lead, the Orioles hung on for their fifth win in 30 games since Aug. 2 when a cat raced on the field in the eighth inning at Yankee Stadium.
Diplan kept the game at 7-4 after Sánchez homered and exited after walking Giancarlo Stanton with one out in the seventh. Tanner Scott stranded two in the seventh and fanned Joey Gallo to end the eighth.
Tyler Wells needed 12 pitches to retire Aaron Judge, Giancarlo Stanton and Anthony Rizzo in a 1-2-3 ninth for his first career save.
Austin Hays and Cedric Mullins homered for the Orioles, who won their first road series since sweeping Washington July 23-25. Jahmai Jones hit a two-run double to start Baltimore’s four-run comeback off Heaney.
Rizzo hit an RBI single as the Yankees, who have four one-run losses to the Orioles this year.
Corey Kluber allowed two runs and four hits in 3 2/3 innings in his second start since missing three months with a strained right shoulder. He struck out five, walked three and threw 78 pitches before the Yankees attempted to piece together the final 16 outs.
Sánchez gave the Yankees a 4-1 lead by capping a nine-pitch at-bat against Keegan Akin.
Sánchez fouled off four straight pitches, took a close pitch to reach a full count and then hit a fastball about halfway up in the second deck in left. The 430-foot blast was his third grand slam and came in his second career start as a ninth-place hitter.
New York took a 5-2 lead in the fifth on Rizzo’s single. Mullins’ 25th homer made it a one-run game before Sánchez went deep again.
Akin allowed four runs and three hits in four innings.
Manager Aaron Boone was ejected after making a pitching change in the fifth. He was upset at ball four to DJ Stewart that replays showed at the top of the strike zone. A YES Network mic picked him up saying: “That’s not even close.”
After lifting Joely Rodríguez for Albert Abreu, Boone walked over to plate umpire Jeff Nelson, gestured a few times and was tossed for the sixth time this year.
Orioles: OF Ryan Mountcastle (right foot) was held out of the lineup after fouling a ball off his foot Saturday.
Yankees: 3B Gio Urshela (left hand) did not start a fourth straight game and is expected to play Monday. He batted as a pinch-hitter in the eighth.
Orioles: Return home for a four-game series against Kansas City on Monday. The Orioles did not announce their rotation.
Yankees: Host Toronto in the opener of a four-game series Monday. RHP Jameson Taillon (8-5, 4.44 ERA) opposes Toronto LHP Hyun Jin Ryu (12-8, 3.92).