WASHINGTON — As the Washington Nationals moved a party 86 years in the making from their ballpark’s infield to a booze-filled clubhouse, manager Dave Martinez paused near the dugout and thrust the silver NL Championship Series trophy overhead, to the delight of loud, delirious fans still in the stands.

Who would have thought this was possible five months ago, when the team was flailing, trade talk was swirling around Washington and folks figured Martinez’s job was in jeopardy?

From 19-31 during a mediocre May to the Fall Classic in an outstanding October — and the city’s first World Series appearance since 1933.

Extending their stunning turnaround, the wild-card Nationals got RBIs from middle-of-the-order stars Anthony Rendon and Juan Soto in a seven-run first inning Tuesday night, and Patrick Corbin’s 12-strikeout performance plus a trio of relievers helped hold on to beat the St. Louis Cardinals 7-4 in Game 4 to complete a sweep in the NLCS.

“Often, bumpy roads lead to beautiful places,” said Martinez, who underwent a heart procedure in September, “and this is a beautiful place.”

Right from the first inning Tuesday, most in a sellout crowd of 43,976 rose from their seats to applaud or yell or twirl their red towels, to chant “Let’s go, Nats!” and “M-V-P!” and various players’ names, enjoying every moment of that game-deciding outburst.

And then, a couple of hours and several innings later, as Tanner Rainey, Sean Doolittle and Daniel Hudson were protecting a shrinking lead, those same spectators stood and shouted and reveled some more.

“I just kept counting down: We’re 12 outs from the World Series. We’re nine outs from the World Series,” shortstop Trea Turner said. “Six. Three.”

Now the Nationals get plenty of time to rest and set up their so-far terrific rotation before beginning the last series of the season against the Houston Astros or New York Yankees in a week. Houston leads the best-of-seven AL Championship Series 2-1 after winning Game 3 at New York 4-1 Tuesday.

The Nationals became the fourth team to reach the World Series after being 12 games under .500.

“We think we can compete with any team, any time,” NLCS MVP Howie Kendrick said. “People always get caught up in the things that are on paper, but the reality of it is you have to go out and play. Once we get out on the field, anything can happen.”

The last time the World Series came to the nation’s capital, more than eight decades ago, the Washington Senators lost to the New York Giants in five games. Have to go even further back, to 1924, for the city’s lone baseball championship, when the Senators defeated the Giants.

The Senators eventually left, and the town didn’t have a major league team at all for more than three decades until the Montreal Expos — who were founded in 1969 and never made it to the World Series — moved to Washington in 2005.

The Nationals had never managed to advance in the postseason since arriving, going 0-4 in the NLDS over the last seven years, including three Game 5 losses at home.

First baseman Ryan Zimmerman, the Nationals’ first draft pick in Washington, was there for all of that heartache.

“Sometimes,” he said, “you got to wait for good things.”

This month alone, the Nationals beat the Milwaukee Brewers in the NL wild-card game after trailing 3-1 heading to the eighth, and eliminated the league-best Los Angeles Dodgers in Game 5 of the NL Division Series after trailing 3-1 heading to the eighth again.

Then came this lopsided dismissal of the NL Central champion Cardinals, who were outscored 20-6 in the series.

“Of course, we could’ve played better,” said St. Louis first baseman Paul Goldschmidt, who was 1 for 16 with nine strikeouts in the NLCS, “but we didn’t.”

Corbin, a left-handed pitcher signed with $140 million of the money that became available last offseason when Bryce Harper left town to join the Philadelphia Phillies, was not quite the equal of Washington’s other starters in the series.

Still, he did become the first pitcher to strike out 10 batters in the first four innings of a postseason game and earned the win after allowing four runs in five innings.

Then Martinez turned to his NL-worst bullpen, such a problem for so much of this season.

After Rainey got three outs, and Doolittle got five, Hudson came in for his fourth save in four chances this postseason. It wasn’t easy, though: After replacing Doolittle with two outs in the eighth, Hudson hit his first batter and walked his second, bringing pinch-hitter Matt Carpenter to the plate as the go-ahead run with the bases loaded.

Carpenter, a career .481 batter with the bases full, grounded out to second baseman Brian Dozier, a defensive replacement who briefly lost the ball before gathering it and throwing to first to end that inning.

Hudson finished things with a perfect ninth, getting Tommy Edman on a fly ball to center field to end it, and red fireworks went off around the stadium.

Corbin got this evening started with a 1-2-3 top of the first, striking out all three Cardinals with a high, 95 mph fastball, a real contrast to the off-speed stuff Stephen Strasburg used for his own dozen Ks a night earlier.

In the bottom half, Washington put up those seven runs, all charged to rookie Dakota Hudson, who lasted all of 15 pitches — doing to the Cardinals what they did in the previous round, when they scored 10 to open Game 5 of the NLDS against Atlanta.

All the heartache of playoffs past seemed to dissipate during an evening that only briefly was tense for the home team and its supporters: In the fifth, a juggled Cardinals lineup finally awoke, scoring three runs — one more than the team managed to produce in Games 1-3 combined — to get within 7-4.

With a man on second and the tying run in the on-deck circle, Corbin came through, striking out St. Louis’ 3-4 hitters, Paul Goldschmidt and Marcell Ozuna, with sliders.

After becoming comeback specialists, the Nationals never trailed against the Cardinals. And dating to the final week of the regular season, Washington has won 16 of its past 18 games.

“We proved — and this doesn’t require advanced sabermetrics,” Cardinals manager Mike Shildt said, “you have to get a lead to win a game.”