The Washington Nationals became the first team to clinch their division this season, doing so mere minutes before the neighboring Baltimore Orioles on Tuesday night. Throughout the 2014 campaign, the Nats have conjured late-inning heroics and convincing blowouts alike while building the best record in the National League, and at 87-64, they’ve still got a shot at matching the 98-win 2012 Nationals for the best record in franchise history.

That’s a damn miracle, considering that just five years ago this was the worst franchise in baseball, and a way station for the damned.

In August of that 2009 season, current general manager and team president Mike Rizzo took over as the full-time GM. He inherited a roster rendered putrid by the late-era Expos’ miserly spending in the draft and international market; the damn-the-future deals by Montreal’s Omar Minaya that cost the franchise Cliff Lee, Grady Sizemore, Brandon Phillips, and Jason Bay; and four years of stewardship by GM Jim Bowden during the early Washington years that bolstered the lineup but left a dearth of pitching.

What’s followed since has been one of the most impressive rebuilding jobs in recent memory. The Nats have gone from losing 102 games in 2008 and 103 in 2009 to being division champs and postseason favorites for the second time in three years. They boast arguably the deepest and most balanced roster in the league, which some close to the team think is even better than the 2012 squad, and they’re a worthy pick to bring a World Series to D.C. for the first time since Walter Johnson’s heyday in 1924, and just the second time ever.

It took a series of winning moves and shrewd maneuvering, plus some good luck and good timing, but the Nats have constructed the best 25-man roster in the NL. Here’s how.

They Got High Draft Picks at the Perfect Time

If a team is going to be bad for a while, it might as well be spectacularly bad and secure better draft slots. Consider Tampa Bay: The Rays’ journey from worst to first took years of clever planning to pull off, but it wouldn’t have happened without the elite talent the team secured thanks to years of high draft picks. David Price, Evan Longoria, B.J. Upton, and Delmon Young all made significant contributions while playing in Tampa Bay and/or fetched significant returns in trades. And look at Houston: The Astros are attempting to emulate Tampa Bay’s turnaround, building around young talent after drafting first overall in three consecutive seasons.

The Nats’ futility led to multiple high picks, specifically four top-10 selections in three years, including consecutive no. 1 overall picks. It just so happened that in 2009 and 2010, the two years in which Washington picked first, Stephen Strasburg and Bryce Harper topped the boards. Since Washington was willing to pay the premium and negotiate with Scott Boras, it drafted franchise players in back-to-back years.

In 2009, the Nats also landed Drew Storen at no. 10 overall as compensation for their inability to sign fellow right-hander Aaron Crow a year earlier; Storen has been a valuable member of the bullpen, and he recently took over for Rafael Soriano as the team’s closer. In 2011, the Nats took infielder Anthony Rendon with the sixth overall pick, and he also looks like a star, ranking fourth among NL position players in Wins Above Replacement this season.

Those four players have combined to give Washington a young, talented nucleus that positions the franchise for success both now and for several seasons to come.

They Inherited Some Useful Pre-2009 Talent

Ian Desmond, one of the last remaining active players with ties to the Expos, was a third-round pick by Montreal in 2004, a few months before the team moved to Washington. Other notable Nats drafted before Rizzo’s arrival include recently activated All-Star third baseman Ryan Zimmerman (fourth overall, 2005); righty reliever Craig Stammen (12th round, 2005); lefty reliever Ross Detwiler (sixth overall, 2007); premium right-hander Jordan Zimmermann (second round, 2007); and utility infielder Danny Espinosa (third round, 2008).

Meanwhile, Tyler Clippard, who was acquired in a Bowden trade, has been one of the best and most underrated Nationals for the past six years. A ninth-round pick by the Yankees in 2003, Clippard was never considered an elite prospect despite some pretty good minor league numbers, including more strikeouts than innings pitched. After a rough debut season in which Clippard posted a 6.33 ERA with the Yankees in 2007, Bowden scooped up the then starter in exchange for fringe righty reliever Jonathan Albaladejo. The Nats gave Clippard two big league starts in 2008, then turned him into a reliever, beginning an excellent and unusually consistent career for a top bullpen arm. In 449 innings of relief, Clippard has recorded 518 strikeouts, a 2.63 ERA, and a tiny opponents’ batting line of just .183/.266/.319. His excellent performance and trademark specs have inspired multiple loving tributes, which is about all a relief pitcher who’s not a fire-breathing closer with loud entrance music and an eight-figure salary can hope for.

They Opened Their Wallets

Washington signing Jayson Werth to a seven-year, $126 million contract in December 2010 is one of those moments that baseball people remember exactly where they were when it happened. Werth was 31 years old with a history of significant injuries, and the Nationals were paying him like one of the best players in the league despite being beyond the age at which most players peak. Rizzo and others in charge argued that Werth’s signing represented a big step forward in the franchise’s quest for respectability, and that his arrival would prompt other big-ticket free agents to follow.

No one followed, and the first two years of that deal were a disaster. Werth hit just .232 and slugged just .389 in 2011, then played in just 81 games the next season. After that second season, I rated Werth’s contract as the fourth-worst in baseball, given his lukewarm performance, injury risk, advancing age, and the five years and $99 million he was still owed. Then, suddenly, Werth got his mojo back. Though he missed 33 games last season, he hit .318/.398/.532 while cranking 25 home runs and ranking among the top players in the league on a per-game basis. And after a lukewarm first three months in 2014, he’s once again gone nuts, batting .311/.434/.558 over his last 61 games and now ranking 10th in the NL in park-adjusted offense.

By Wins Above Replacement per dollar and pretty much any other formula, Werth’s deal will likely still wind up looking like an overpay when it finally expires in 2017. But given Werth’s improvement and the team’s nucleus of young, affordable stars, nobody seems to mind these days.

They Built Out the Rest of the Roster Masterfully

The Nats had problems last season, but starting pitching wasn’t one of them. Washington starters put up a 3.60 ERA in 2013, the seventh-best mark in the majors, and a 3.58 FIP, the sixth-best mark and a virtual tie with the Braves for fifth. With a top three of Strasburg, Zimmermann, and Gio Gonzalez, the Nats could have slotted in any half-decent starters in the fourth and fifth spots and still ranked among the best rotations in the league.

Rizzo decided he could do better. When the Tigers reckoned they had too many good starting pitchers, the Nats’ GM pounced, acquiring veteran right-hander Doug Fister for three players: utility infielder Steve Lombardozzi, young lefty reliever Ian Krol, and pitching prospect Robbie Ray. Whatever the Tigers’ true motives — making room in the rotation for young lefty Drew Smyly, shedding a few million dollars in the hopes of parlaying that money into a Max Scherzer contract extension, or whatever post-hoc explanation might best fit the narrative — the Nats got a steal. Though Fister’s strikeout rate has dropped to its lowest level since 2010, he’s made up for it with the trademark pinpoint control that’s netted the second-lowest walk rate among NL starters. That level of precision, a defense that’s leaps and bounds better than the Swiss cheese unit Fister’s former team rolled out last year, and a little luck have combined to produce the NL’s fifth-lowest ERA for pitchers with as many innings, with Fister trailing only leading Cy Young shoo-in Clayton Kershaw, plus Johnny Cueto, Adam Wainwright, and Cole Hamels.

Fister wasn’t the only nifty trade acquisition. The guy behind him in the rotation this season, Tanner Roark, was a 25th-round pick by the Rangers in 2008, and was acquired for a marginally useful player (Cristian Guzman) at the 2010 trade deadline. In his first full big league season, Roark is sporting a sparkling 2.85 ERA and has grown into the best fifth starter in baseball.

Denard Span, meanwhile, has been on fire since Harper indirectly lobbied for Span’s benching, batting .336 with a .395 on-base percentage since July 1, providing a huge boost at the top of the lineup. Span was also acquired in a Rizzo trade, coming over from Minnesota for pitching prospect Alex Meyer in November 2012, giving the Nats an incredibly rare commodity: a true two-way center fielder who can get on base, steal bases, and play good defense at a key position, and all for a very attractive salary (he’ll have made $20.25 million over three years in D.C. after the Nationals pick up his $9 million club option next year).

But wait, there’s more. They got Wilson Ramos, a 27-year-old catcher who can actually hit, in a heist of a deal with the Twins that cost them then closer Matt Capps, who last pitched in the big leagues in 2012. Former A’s starter Gonzalez was by no means a steal since he cost the Nats multiple young players, including 2014 All-Star catcher Derek Norris, but he’s still been an asset in D.C. despite some struggles this year. And while we might not see another Werth-level free-agent deal for a while, mid-tier pickups like Adam LaRoche have ably filled holes without breaking the bank. Even the team’s bit players look formidable, with the bullpen going five-deep in quality options, and the bench getting stronger thanks to the deadline pickup of Asdrubal Cabrera that nudged Espinosa back to a reserve role.

Add it all up and the Nats have crafted an enviable blueprint for any rebuilding team, combining smart drafting, aggressive deal making, the requisite amount of luck, and a willingness to spend and take risks. Whether due to financial limitations or general inertia, too few clubs follow a similar path.

The scary thing is that for much of this season, the Nationals failed to play their best baseball. Strasburg scuffled for a good chunk of the year, producing strong advanced stats but sometimes erratic results; he’s looked better lately, though, posting an unfathomable 28 strikeouts and zero walks in his last four starts. Meanwhile, while a thumb injury cost Harper time and hindered his swing for a big chunk of the season, he’s mashed seven homers and batted .288/.329/.563 over his last 22 games. If those two young stars keep it up, the Nationals might be entering the playoffs as a team without a true weakness.

For a club that’s trying to bring its city the first World Series crown since the 1920s, that’s a great place to be.