WASHINGTON — Baseball has had a long, agonizing history in the nation’s capital, where decades of abject failure led teams to abandon the city and seek success elsewhere. But now, after 86 years and the departure of two franchises, Washington will finally host a World Series again.

The Washington Nationals beat the St. Louis Cardinals, 7-4, on Tuesday to complete a four-game sweep in the National League Championship Series and clinch the first pennant for a Washington team since the Senators did it in 1933.

When center fielder Victor Robles caught the final out, the Nationals players poured out of their dugout to celebrate the culmination of a pursuit that included 33 years without a major league team in the city.

One of the celebrants was first baseman Ryan Zimmerman, the longest-serving member of the team. He was called up from the minors in 2005, the year the Montreal Expos moved to Washington and became the Nationals.