NEW YORK (AP) — Things were getting beyond dicey for Brad Brach and the Baltimore Orioles.

Bases loaded, no outs. Clinging to a one-run lead in the 12th. Big boppers Aaron Judge and Giancarlo Stanton coming up.

But boosted by an alert play from catcher Caleb Joseph, Brach escaped his own jam. And after overcoming an early deficit that left their starting pitcher punching the dugout wall, the Orioles held off the New York Yankees 8-7 Sunday.

"I just wanted to do my job after the guys before me got it to the 13th, 14th, whatever inning it was," Brach said.

"Had it the whole time," he added, with a smile.

The Orioles arrived at Yankee Stadium this week with a five-game losing streak. Craig Gentry's RBI single in the 12th helped them take three of four — the first time they've won three in any series in the Bronx since 1997, at the old park across the street.

"That was fun," Orioles manager Buck Showalter said.

It didn't look that way after Brach walked the first two batters and fumbled a bunt for an error.

"I knew their lineup, I knew who was coming up," Brach said. "I just tried to slow things down, take it pitch by pitch."

Judge hit a comebacker to Brach, who threw home. Joseph quickly whipped the ball to third base for a rare 1-2-5 double play.

"I always wondered why guys didn't try to go to third base there," Joseph said.

Brach struck out Stanton for his second save.

Stanton went 0 for 7, stranded nine runners and fanned five times for the second time in a week — the only two times the NL MVP has done that in his professional career.

Stanton is hitting .167 and has 20 strikeouts in 42 at-bats in his first year with the Yankees, and getting booed by the home fans.

"They're not going to cheer for that, so what do you expect?" Stanton said.

"Just got to look at it as a bad week. Season is much longer than a week, so a couple good games can turn it around and help us win," he said.

Anthony Santander's first major league homer, a two-run drive, and a two-run shot by Danny Valencia let the Orioles rally from down 5-0.

Pinch-hitter Pedro Alvarez, whose 14th-inning grand slam won Friday night's game, drew a one-out walk in the 12th from Adam Warren (0-1). Santander singled with two outs and Gentry capped an 11-pitch at-bat with a go-ahead single.

Gentry helped preserve the tie with a twisting, diving catch in left field that took away a potential winning hit from Brett Gardner in the 10th.

Richard Bleier (1-0) pitched three scoreless innings.

This was the first series for the Yankees with two games going at least 12 innings since 2001 at Veterans Stadium in Philadelphia.

READY TO RUMBLE

Baltimore starter Mike Wright Jr. got only two outs, made a throwing error and was tagged for five runs.

"It was pretty awful," Wright said.

Frustrated, he then tagged the padded dugout wall with a five-punch combination. The righty alternated the blows, starting with his pitching hand.

Asked if he hurt himself, he simply said: "No, it's padded."

JUDGE THIS

Judge's franchise record of 14 straight home games with an RBI ended. He singled twice, including a five-hop dribbler that caromed off the first base bag. He has a 16-game hitting streak at home.

TRAINER'S ROOM

Orioles: 1B Chris Davis didn't play. He hasn't been feeling well and hasn't slept much, Showalter said.

Yankees: Didi Gregorius didn't start for the first time this season. He got jarred on a headfirst slide home Friday night and is "a little beat up," manager Aaron Boone said. Gregorius pinch-hit and stayed in at shortstop. He got a gift double in the 10th when CF Adam Jones lost his routine flyball in the sun. ... C Gary Sanchez (leg cramp) got a second day off in a row.

UP NEXT

Orioles: Return home to play Toronto on Monday. RHP Dylan Bundy has pitched well in two starts, getting no-decisions vs. Minnesota and Houston. He's allowed just one run in 13 innings, striking out 15.

Yankees: After a day off, New York opens a three-game series at Boston. RHP Luis Severino (2-0, 1.38) faces LHP Chris Sale (0-0, 0.82). Boone faces the Red Sox for the first time with the Yankees since hitting an 11th-inning home run to win Game 7 of the 2003 ALCS at Yankee Stadium. "I hear about it all the time. I heard about it on the ride into the park today from our Uber driver. He had a story involved," Boone said. The man remembered getting so excited, he jumped over something and cut his arm, Boone relayed.

___

More AP baseball: www.apnews.com/tags/MLBbaseball