For indispensable reporting on the coronavirus crisis, the election, and more, subscribe to the Mother Jones Daily newsletter.

After the 2016 election, Alexandria Ocasio-Cortez was working as a bartender in Union Square when she decided to take a road trip. An activist she knew at Standing Rock, where indigenous activists were leading a demonstration against the construction of the Dakota Access Pipeline, told her the camp could use more women. So the then-27-year-old Ocasio-Cortez and two friends set up a GoFundMe page, loaded up a car full of supplies, and set out for South Dakota.

Ocasio-Cortez’s win was years in the making, the outgrowth of grassroots resistance not just to Trump but to New York’s entrenched powers.

Still shaken by the election of President Donald Trump, they brought a camera and logged hours of footage talking with people along the way—small business owners in Ohio, housing experts in Flint, Michigan. They made it to the high plains before Christmas and then lived for weeks among Standing Rock’s water protectors in a tent with a wood-burning stove. Ocasio-Cortez was seeking a “first-person idea of what was going on” in America, she told me when we spoke last fall. What she found was that “militarized corporations” were taking over parts of the country, unchecked by political powers.

Not long after she left the encampment for good, she got a call from the executive director of a group called Brand New Congress, a project recently launched by a group of progressive organizers, mostly fellow backers of Vermont Sen. Bernie Sanders, who were frustrated with the party’s entrenched establishment and wanted to train a slate of primary candidates. Would she have any interest in running for Congress?

The rest, of course, is history. On Tuesday, Ocasio-Cortez scored the biggest Democratic primary upset in years, knocking off Democratic caucus chair—and Queens Democratic boss—Joe Crowley. She will almost certainly become the youngest woman ever elected to the House of Representatives this fall. Her victory was so comfortable it almost looks inevitable. It wasn’t. Ocasio-Cortez’s win was years in the making, an outgrowth of a grassroots resistance not just to President Trump but to the entrenched political powers in an ostensibly blue state. To the party’s leadership, Tuesday was a wake-up call; to the the party’s left flank, it was validation of the tactics and messaging they’ve been pushing for months.

https://twitter.com/bendreyfuss/status/1011822342740291584

Start with Brand New Congress. Ocasio-Cortez is the first candidate backed by the organization to unseat an incumbent, which, after all, is the group’s stated aim. The organization, which has backed 26 House and Senate candidates in 2018, was an important incubator during the early phase of her campaign. She attended trainings with the group in Kentucky and then again in Tennessee, and she was in constant contact with other candidates via Slack or email, sharing talking points about issues like Black Lives Matter or pension reform and exchanging best practices for door-knocking. The campaign, in the end, was her own, but it was a collaborative effort getting off the ground. She likely wouldn’t have run in the first place if she hadn’t been recruited, and her ubiquitous purple-and-white campaign T-shirts were spinoffs of a standard Brand New Congress design. Primary challengers almost never work, in part because there’s rarely a natural constituency behind them. But Ocasio-Cortez never had that problem; she started off with a base and resources marshaled by the party’s anti-establishment wing.

The 14th District, which includes parts of the Bronx and Queens, was also uniquely susceptible to this kind of insurgency. Crowley may have never faced a serious primary challenge before, but the Democratic party in the area had just suffered a series of shocks. The first was the 2016 presidential primary itself. Sanders’ rally in the South Bronx, Ocasio-Cortez said, was the first held there by a major-party candidate since Robert F. Kennedy. Sanders didn’t come all that close in New York City, but it was an unusually frenzied burst of organizing activity in a place that is low-turnout by design, and it also left a lot of progressive activists tasting bad blood. Hundreds of thousands of voters had been blocked from voting—including Ocasio-Cortez, whose registration had been mixed up during Hurricane Sandy. Other Sanders supporters ran up against the laws that cut off party registration changes half a year before the primary.

Ocasio-Cortez turned out to be really good at politics; lots of long-shot candidates aren’t.

Building on the lessons of that race, Ocasio-Cortez’s campaign placed a big emphasis on small-d democracy. When I tagged along with her volunteers on a canvassing walk in September, they were going door-to-door in Woodside, Queens, to alert unaffiliated voters of the looming deadline to change their party registration to Democrat. (Ocasio-Cortez had to bail at the last minute—she had to take a shift at the restaurant.)

The second shock came after the election, when a state senator in Queens announced he was joining an Albany legislative faction known as the Independent Democratic Caucus—a move that essentially threw his support to the Republican leadership in Albany. In the ensuing months, his district became the site of a huge grassroots fight against the IDC and Democratic leaders (chiefly Gov. Andrew Cuomo, but also Crowley) who hadn’t done enough to stop them. The IDC members all got primary opponents, and eventually, Cuomo did too. In New York City, people were upset about Trump but didn’t have any Republicans to take it out on. So they focused their energy on other Democrats.

Does this look like the kind of place that’s ripe for an anti-establishment takeover? Yes, yes it does:

Inside the JH Jewish Center for wild town hall meeting with Sen. Jose Peralta https://t.co/x7mjcJrjwq — katie honan (@katie_honan) February 3, 2017

These were the conditions in which a long-shot primary quietly gained traction. But Ocasio-Cortez won, above all else, because of Ocasio-Cortez. Although Crowley checked a lot of the normal progressive political boxes, he was also a white guy who represented, often from afar, one of the most diverse communities on the planet. Ocasio-Cortez argued that residents of a heavily Latino district had something to gain something by electing a Spanish-speaking, working-class, 28-year-old Puerto Rican. The fact that her opponent couldn’t pronounce “nixtamal” on the eve of the primary wasn’t just a goofy food gaffe; it was precisely her point.

That cultural disconnect was attached to real political concerns. Ocasio-Cortez was one of the first Democratic House candidates to call for abolishing the Immigration and Customs Enforcement agency, known as ICE, which she called “authoritarian” and “a weapon waiting for a tyrant.” On the weekend before the primary, she left her district to travel to a detention facility in Tornillo, Texas, to protest the separation of migrant parents from their kids. She was a candidate for the Trump era, conveying a sense of urgency that matched the frustrations and fears of her electorate.

The candidates’ exchange on ICE at a debate last week illustrated this dynamic quite neatly. Crowley had recently tried (unsuccessfully, it turned out) to get arrested at an immigration protest and had called ICE “fascist.” But Ocasio-Cortez shut him down:

ICE is operating exactly as designed when it rips screaming children from parents. That’s exactly why we must abolish it. We MUST have the moral and political courage to #abolishICE. Weak half-measures do nothing. This is a defining moment of our time – the time to act is now. pic.twitter.com/0viiQ4qdz8 — Alexandria Ocasio-Cortez (@AOC) June 19, 2018

At her victory party on Tuesday, she put it another way: “There is nothing radical about moral clarity.”

Besides abolishing ICE, she pushed a platform befitting someone who touted her Democratic Socialists of America membership in a campaign ad—Medicare for all, a federal jobs guarantee, tuition-free college, a 50 percent reduction in the federal prison population, and a Marshall Plan for Puerto Rico. Above all, she channeled Sanders’ attacks on the party’s corporate wing. While calling housing “a human right,” she hammered Crowley for his ties to luxury real-estate developers—a live wire in a district where renters are feeling the squeeze while skyscraper units, some used for money laundering, sit empty. It’s not a coincidence that both Ocasio-Cortez and Adem Bunkeddeko—who nearly upset Rep. Yvette Clarke in the nearby 9th District—both made affordable housing a central tenet of their candidacies. These are the kinds of issues that often dominate local races. But they don’t have to stay local issues.

Luxury developers are attempting to build a massive and unaffordable development in heavily working-class Queens. I’m here to testify against it – along with many others here. This is the scene of #Resistance at the Community Board 4 meeting in Elmhurst right now: pic.twitter.com/34Jr8vaumX — Alexandria Ocasio-Cortez (@AOC) March 14, 2018

What happened in the 14th District isn’t a formula that will work everywhere. Most places aren’t as full of voters as disconnected from their party leadership as New York City is, and few longtime incumbents are as ill-prepared for a brawl as Crowley was; he had been gifted the seat by his predecessor without ever having to fight for it. Ocasio-Cortez turned out to be really good at politics; lots of long-shot candidates aren’t. And it probably helps that Republicans don’t have a prayer of winning a congressional election in Jackson Heights. But many Democrats, including Crowley, may have written off Ocasio-Cortez because of her youth and lack of institutional support. Instead, she won because of that. And after Tuesday, a lot more young progressives just might think they can, too.