The Yankees' Aaron Judge, right, celebrates after his solo home...

The Yankees' Aaron Judge, right, celebrates after his solo home run with Ben Rice hit off Orioles pitcher Grayson Rodriguez during the fifth inning of a game on Saturday in Baltimore. Credit: AP/Terrance Williams

BALTIMORE — And just like that, they’re tied.

The Yankees, who got a three-run home run from Austin Wells in the first inning, back-to-back homers by All-Star starters Juan Soto and Aaron Judge in the fifth and a second straight dominant effort from Luis Gil, pulled into a virtual tie with the Orioles atop the AL East with a 6-1 victory over Baltimore on Saturday in front of a sellout crowd of 44,018 at Camden Yards.

After going 7-16 in their previous 23 games before beginning this series, the Yankees (58-39, .598 winning percentage) have reversed that downturn in the past two days.

In the process, they handed the Orioles (57-38, .600) a fifth straight loss. Baltimore has managed only two runs in its past 42 innings.

“It’s always great to win a series. Definitely, we needed it big time to bounce back and get on track,” Juan Soto said of the Yankees doing so for the first time since taking three of four from the Royals in Kansas City from June 10-13. “Things weren’t going our way, but we kept trying until we find a way. We did a great job today and try to get the sweep tomorrow.”

The Yankees, who earned a 4-1 victory over the Orioles on Friday night, won a second straight game for the first time since June 11-12. In their previous eight series, they had lost seven  and tied one.

Flashing an especially live fastball and darting slider, Gil (10-5, 3.17) allowed one run, five hits and a walk in six innings in which he struck out seven. After giving up 16 runs, 14 hits, nine walks and five hit batsmen in 9 2/3  innings in a three-start span (14.90 ERA), Gil has allowed two runs, nine hits and one walk with 16 strikeouts in 12 2/3 innings in his last two starts (1.42 ERA).

In the first of those three bad starts, Gil allowed seven runs, eight hits and two walks in 1 1/3 innings in a 17-5 loss to the Orioles on June 20.

As impressive as Gil’s overall performance has been in the first half, it doesn’t compared to that of Judge, whose MLB-leading 34 homers are the most by a Yankee in franchise history before the All-Star break (which dates to 1933).

“That was my guess for what he would have [at the break] last time we were here,” Wells said with a smile of Judge’s homer total.

Indeed, on May 2, when the Yankees left here having lost three of four and a slumping Judge was hitting .197 with six homers in 33 games, the rookie catcher predicted to reserve Jahmai Jones that Judge would have 34 homers and 85 RBIs by the time the All-Star Game rolled around. Judge has 85 RBIs with one game to go on Sunday.

“Getting to be in the dugout and watching him do that, I can’t put it into words because I’ve never seen anything like it before. It’s super-special and just unbelievable,” said Wells, whose blast with two outs in the first inning gave Gil a four-run cushion before his first pitch of the day.

Said Judge of his early-season struggles: “We were winning ballgames, that’s all that really mattered to me. You’ve got 500, 600 at-bats to figure it out. We’re putting ourselves in a great position heading into the All-Star break and that’s the most satisfying thing.”

Orioles righthander Grayson Rodriguez, 11-3 with a 3.52 ERA entering the game, including 5 2/3 scoreless innings against the Yankees in a 2-0 victory here on April 29, found barrels throughout. He allowed six runs and eight hits in five innings in which he walked one and struck out seven.

Alex Verdugo led off the game with a single, Soto took his spot at first after a 4-6 forceout and Judge walked for the fifth time in two games. Ben Rice struck out for the second out, but Gleyber Torres bounced a sharp grounder back up the middle that All-Star shortstop Gunnar Henderson couldn’t quite get to for an RBI infield single and a 1-0 lead.

Wells then showed why he already was starting to assume primary catcher duties well before Jose Trevino landed on the injured list Saturday with a quadriceps strain. On the ninth pitch of his at-bat and Rodriguez’s 28th pitch of the inning, Wells hammered a 2-and-2 slider 397 feet to rightfield onto Eutaw Street for a 4-0 lead.

“Great at-bat. Huge shot in the arm for us,” Aaron Boone said of Wells’ homer. “To throw a crooked one like that in the first . . . A lot of good at-bats to give us an opportunity there and then a [nine-pitch] at-bat, finally got a mistake and he didn’t miss it. The guys were off and running after that.”

In the fifth, Soto hit a 0-and-1 changeup 426 feet to centerfield for his 23rd homer and Judge  blasted a 2-and-2 changeup 431 feet to center for a 6-1 lead.

Despite going eight games without an extra-base hit recently, Judge recorded his 28th home run in his past 60 games. He also doubled in the third.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME