WASHINGTON — Washington’s Juan Soto delivered a bases-loaded single against Josh Hader that scored three runs with two outs in the bottom of the eighth inning, and the Nationals rallied to beat the Brewers 4-3 in the NL wild-card game Tuesday night.

After Hader loaded the bases by hitting one batter, walking another and allowing a broken-bat bloop single, Soto took a 96 mph fastball to right, and the ball skipped under outfielder Trent Grisham’s glove for an error. That allowed the go-ahead run to cross the plate and Soto to get to second, then turn for third.

Eventually, Soto, a 20-year-old outfielder, was caught in a rundown to end the inning, but that didn’t matter: He had turned a 3-1 deficit into a lead, and so he clapped his hands, then pounded his chest and high-fived third base coach Bob Henley, shouting “Let’s go!”

“The inning was an ugly inning,” Brewers manager Craig Counsell said. “Crazy things happen.”

Grisham’s take?

“It’s gonna sting,” he said.

Stephen Strasburg threw three scoreless innings to earn the win in the first relief appearance of his major league career, regular season or playoffs.

Daniel Hudson pitched the ninth for the save. With a runner on, Ben Gamel flied to the warning track in center for the final out.

The Nationals, so familiar with playoff heartache, now will carry a nine-game winning streak into their best-of-five NL Division Series against the NL West champion Dodgers.

Game 1 is Thursday in Los Angeles, and some in the sellout crowd of 42,993 chanted “Beat LA! Beat LA!” as members of the Nationals lingered on the infield with family members after the rare playoff triumph for a franchise that had never before advanced in the playoffs since moving to Washington from Montreal before the 2005 season.

“We’ve been here a bunch of times. Never kind of broke through,” said Ryan Zimmerman, the Nationals’ first draft pick back in 2005, who singled as a pinch hitter in the eighth. “Finally caught a break tonight.”

Yes, Washington had been 0-3 in winner-take-all postseason games, all NLDS Game 5 losses at home.

But this time was different. Thanks, in large part, to one of the kids making his debut in October, Soto, who is wholly unencumbered by any past playoff failings on this stage and in this stadium.

Still, things didn’t look good early for Washington.

Yasmani Grandal and Eric Thames homered in the first two innings off Nationals ace Max Scherzer, a three-time Cy Young Award winner whose teams had lost each of his most recent seven postseason games.

Milwaukee led the NL in walks, and Scherzer put leadoff man Grisham aboard.

The first pitch to the next batter, Grandal, came in at 98 mph and was transformed into a blink-and-you-missed-it shot that rapidly reached the bullpen beyond right field. The ball landed with such force that it bounced back onto the outfield grass.

Just like that — three minutes and seven pitches into the evening — the Brewers led 2-0.

The once-rowdy park sunk into sudden silence. Strasburg paced in the bullpen.

Milwaukee went up 3-0 in the second when Thames’ first career postseason at-bat ended with him driving a curveball deep to right-center.

Washington got one run off Brandon Woodruff on a solo shot from Trea Turner in the third off a high fastball, making it 3-1.

Woodruff, a burly righty, lasted four innings, giving up just two hits, and was greeted by hugs from teammates in the dugout.

That’s when Counsell began his maneuvers, going to Brent Suter for the fifth, then Drew Pomeranz for the sixth and seventh, before turning to the lefty fireballer Hader. The Nationals’ bats finally got going — and their team’s dramatic turnaround from 19-31 in May to playoff team gets to continue.

“Everything changed,” Soto said. “The energy of the team, it changed.”