This may be only the second postseason this century to involve both the Mets and Yankees. Photo: Patrick Semansky/AP Photo

My friend Jason Fry is a best-selling author, a former Poynter fellow, and an award-winning journalist. But none of these things matter to him nearly as much as his side project: being a Mets fan. Along with his writing partner Greg Prince, Jason has run the Mets blog Faith and Fear in Flushing for more than a decade — a decade that happens to have been the most painful one in the history of a franchise that knows pain, a decade he’s nevertheless managed to chronicle with intelligence and good humor. This is a signature of Mets fans: Kick them in the face for 30 years and they’ll feel every thwack, but they’ll never truly give up. After all, you gotta believe.

Then, on July 8 of this year, Jason lost all hope. The Mets were only two games over .500, three games behind the Nationals, and causing, through their offensive ineptitude, broadcaster Keith Hernandez to have nightly meltdowns on-air. “Contraction is the answer,” Jason wrote. “This baseball team is killing me and 500,000 other dummies who need an intervention.”

And look at us now. Wobbly as they sometimes can seem, the Mets have, shockingly, taken control of the NL East in the second half of the season, and meanwhile, in the Bronx, a Yankees team picked by many not only to miss the playoffs but to finish last in a difficult AL East is on the brink of the playoffs, too. (While the Yankees look unable to catch the Blue Jays in the AL East, they’re in prime position to claim a wild-card spot and break their two-year postseason drought, their longest since 1994.) This may be only the second postseason this century to involve both the Mets and Yankees, and these days, you can even imagine a Subway Series in October in addition to the one this weekend. But for all the talk of a resurgence, and of the city being gripped by baseball again, it is worth remembering that none of this was certain not so long ago. The Mets and Yankees are back, and they’ve both made some smart moves to get there. But let’s not pretend any of this went according to plan.

First, the Yankees. In 2013, Mark Teixeira and Alex Rodriguez made $50.5 million — more than two teams’ entire payrolls — and for that, the Yankees received ten homers in 209 at-bats and a fourth-place finish. At that point, the team still owed the two men a combined $133.5 million. In 2014, Rodriguez was famously suspended all season — saving the salary, at least — and Teixeira had the worst season of his career, batting only .216. It was unreasonable to expect much out of either one of them in 2015 … and then each of them went out and pretended like it was 2009. Teixeira hit 31 homers and played solid defense at first base, making his first All-Star team since 2009, before suffering a season-ending leg injury in August. And A-Rod — many wondered whether he could physically swing a bat coming into the season — has been even more of a revelation, hitting 32 homers himself and serving as an anchor for a spotty, aging offense. The Yankees had zero hope for either this year, and each player performed like an all-star. It’s not often season savers fall from the sky like that.

And then there are the Mets. The thing about Jason’s mid-July panic was that it wasn’t unwarranted. The Mets were hanging around the Nationals in the NL East, but the triumvirate of outstanding teams in the NL Central (the Cardinals, the Pirates, and the Cubs have had the best records in the league for most of the second half) meant there would be no wild card to fall back on: The Mets would have to catch the Nationals to make the postseason. This was particularly frustrating, not just because the Mets’ dominant young rotation — considering the fragility of young arms — felt like a once-in-a-generation opportunity that was going to waste because of an offense that ownership refused to upgrade, but also because everyone knew the Nationals were about to take off. This was a team some projected to win 108 games this season, with its all-world rotation and solid lineup, led by Bryce Harper, finally having his breakthrough season. The Mets had some exciting pitching — if you squinted, it could even look like the foundation of a dynasty — but their offense was terrible. It was only a matter of time before the Nationals hit the gas and left the Mets in the dust.

Oops. The Nationals imploded, and now appear to be an organization in total chaos. (Maybe it’s the football team across town rubbing off on them.) And Flushing has been having a nonstop party for two months. Who knows how smoothly the rest of the season will go. But for a while it’s seemed like every day is another come-from-behind win. (The Mets are the team with clubhouse cohesion these days. The Mets!) In fact, the trade deadline, which was supposed to be the signifier of Mets ownership’s inability to help out their desperate team, actually became the turning point: The Mets kept Wilmer Flores, who cried on the field when he thought he’d been traded but has keyed several spectacular wins since; added Kelly Johnson and Juan Uribe, probably thinking they shouldn’t expect anything from a seemingly terminally injured David Wright; then welcomed back their captain and watched him hit a first-swing home run and settle right back into being a regular; and, most of all, traded for Yoenis Céspedes, the larger-than-life slugger Mets fans have been waiting for since Mike Piazza. (Céspedes has instantly become your kid’s favorite player ever.) On July 23, the Mets ran out a cleanup and fifth hitter batting .170 and .179 — the second-worst pair in those lineup spots in the live-ball era. Now they have the luxury of batting Céspedes second, even as he’s hit more home runs since being traded at the deadline than anyone in baseball history not named Mark McGwire or Manny Ramirez — and Céspedes still has three weeks to go.

Céspedes hasn’t just been the most significant trade-deadline acquisition in recent memory; he’s been the emotional driver of this surge. And he wouldn’t even be here had the initial trade for Carlos Gómez — the one that made Flores cry on the field, the one that turned out not to be — gone through. Gómez has hit just .234 since the trade deadline, when the Astros picked him up, laughing that the Mets had completely bungled things — not to mention the .172 average since then of Jay Bruce, whom the Mets tried to get before they moved on to Céspedes. Céspedes changed the Mets’ whole season. And he’s here almost by accident. Plus, he’s behind another accident: The Mets have only been able to keep rookie Michael Conforto around because Céspedes told them he could play center field in addition to his more natural spot in left. Last summer, Conforto was just starting pro ball in Brooklyn, and nobody in the organization thought he was ready for the majors; now he’s hitting like a batting champion.

But accidents, and happenstance, and goofy luck — all of those impossible-to-predict quirks of a long baseball season — none of those matter once you’re in the postseason. All you need in this mad scramble, one that featured two wild-card teams in the World Series last year, is a ticket to ride. And as far as October is concerned, Alex Rodriguez has always been everybody’s favorite Yankee, and Yoenis Céspedes was meant to be a Met from birth. In the postseason, it doesn’t matter who you were. It matters what you are. And these two teams have as good a chance as anyone.

The Mets’ postseason advantage is self-evident: A rotation like theirs, with an offense as hot as theirs has been of late, is precisely the recipe for a deep October run. No team in baseball, not even the Mets’ likely divisional-series opponent the Dodgers (with Clayton Kershaw and Zack Greinke atop the rotation), wants to deal with deGrom, Syndergaard, Harvey, and Matz in a five-game series. (Some of these pitchers may be tired now, but the Mets have the depth to rest them, and enough of a lead to do so comfortably.) But the Yankees have assets that shine in the postseason as well, particularly that bullpen, which shortens games considerably — even more when, thanks to extra days off, you can use pitchers like Andrew Miller and Dellin Betances in multiple innings every day. If the Yankees get an early lead, the game’s nearly over. So if they can escape the coin-flip wild-card game, a Subway Series looks far from an impossibility.

*This article appears in the September 21, 2015 issue of New York Magazine.