The Nationals' Juan Soto watches his home run in front...

The Nationals' Juan Soto watches his home run in front Yankees catcher Austin Romine during the seventh inning of a game Wednesday at Yankee Stadium. Credit: AP / Bill Kostroun

It was one of the few times this season — maybe the only time — that the Yankees didn’t have the most impressive rookie on the field.

Although Gleyber Torres, a strong American League Rookie of the Year candidate, hit his 12th homer, 19-year-old Nationals outfielder Juan Soto stole the show Wednesday night, hitting two homers and driving in four runs in Washington’s 5-4 victory at the Stadium.

“He’s been really good since he came up,” Aaron Boone said. “From where he started this year to be here, there’s good reason, and we got a peek at it tonight.”

The Yankees, who had won 12 of 16, fell to 43-20.

Soto hit a three-run homer off Sonny Gray in the fourth inning to give the Nationals a 4-3 lead. Soto also connected off Chasen Shreve in the seventh, snapping a tie at 4 and ending a streak of 23 scoreless innings by the Yankees’ bullpen. Soto began the season in Low-A ball and was called up to the majors from Double-A on May 20.

“A couple of big swings that beat us, ultimately,” Boone said. “But obviously a good-looking young player.”

Torres’ blast, a 435-foot shot to left-center in the fifth, had tied it at 4.

Soto, at 19 years, 231 days old, is the youngest to hit a home run in either Yankee Stadium since Ken Griffey Jr., at 19 years, 190 days old, went deep twice May 30, 1989, for the Mariners. Soto is hitting .344 with five homers in his first 20 games.

Gray entered 4-4 and his ERA rose to 4.98. He was 2-1 with a 2.45 ERA over his previous four starts, but he pitched more to the season home numbers he toted into the game — 2-2, 7.22 ERA in six Stadium starts. Gray allowed four runs and seven hits in five innings, which included a 34-pitch first.

The Yankees had their share of chances but went 1-for-7 with runners in scoring position and stranded five. After they wasted a Greg Bird double in the seventh, they stranded two more in the eighth. Bird had two hits, including a homer.

Sean Doolittle pitched a perfect ninth for his 17th save.

The Yankees built a 3-1 lead through three innings. They got a first-inning sacrifice fly by Aaron Judge, a second-inning homer by Bird, who came in 9-for-51 (.176), and an RBI single in the third by Giancarlo Stanton, who had three hits.

The Yankees also were aided by baserunning incompetence by the Nationals, who made four outs on the bases — including two pickoffs by Gray — in the first three innings.

But Gray walked Daniel Murphy with two outs in the fourth, allowed a single to Matt Adams, then missed with a 1-and-0 fastball to the lefty-hitting Soto, who sent it down the leftfield line and just over the wall for the 4-3 lead.

“We were trying to throw a fastball in and it went up and away,” said Gray, who was far more angry about the Murphy walk than the home-run pitch. “Two-out walks will always hurt you and today . . . you saw it. They can escalate, and that’s what happened.”

Shreve pitched a scoreless sixth, then retired Adams to start the seventh before Soto crushed a 1-and-0 fastball an estimated 436 feet to right-center for the 5-4 lead. Shreve said the pitch was meant to be “down and away” and “I missed my spot” in the middle of the plate.

“You miss your spot to any big-league hitter, they’re going to get you when you’re behind in the count,” Shreve said. “I didn’t do my job and we lost the game because of it.”

More Yankees headlines

Newsday LogoSUBSCRIBEUnlimited Digital AccessOnly 25¢for 5 months
ACT NOWSALE ENDS SOON | CANCEL ANYTIME