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

On the Thursday before New York’s June congressional primary, Alexandria Ocasio-Cortez, the 28-year-old democratic socialist, and Rep. Joe Crowley, the chairman of the House Democratic Caucus, gathered for their second and final debate at a Jewish community center in Queens. Ocasio-Cortez’s stunning primary victory five days later would shake up the Democratic Party and elevate her most notable campaign trail pledge—the abolition of the Immigration and Customs Enforcement agency—to the top of the national political conversation. But on that particular night, the looming showdown in the 14th District wasn’t even the most contentious primary fight on the lineup.

That was the face-off between two Democratic candidates for the New York state Senate, the incumbent Sen. Jose Peralta and his challenger Jessica Ramos. Their primary isn’t until September—New York is the only state with separate primaries for federal elections—but the campaign had taken on a heated and distinctly personal tone.

On paper, Peralta and Ramos aren’t far apart. Ramos wants a DREAM Act for New York state; the incumbent boasts of being the bill’s lead sponsor. They both cite passage of the New York Reproductive Health Act (which would codify Roe v. Wade into state law in case the US Supreme Court overturns the right to an abortion), single-payer health care, and affordable housing as priorities.

What’s happening in New York in some ways reflects the larger struggle playing out within the Democratic Party, in which progressive insurgents frustrated with the pace of change have taken the fight to lawmakers they believe are holding the party back.

“He’s still a traitor,” she says. What separates them—and the reason why a standing-room-only crowd was heckling the incumbent three months before a primary that would ordinarily pass by with hardly a peep—was a decision Peralta had made a little more than a year earlier. In January 2017, he joined a breakaway faction in Albany, known as the Independent Democratic Conference, which voted to give Republicans control of the chamber in return for a set of perks, including committee gavels, special pay raises, and extra funding for district projects. Peralta, who rejoined the Democrats when the IDC finally broke up in April, boasts that the arrangement helped him bring home $10 million for immigrant legal services. But by that point, in Ramos’ view, the damage had been done—he had abandoned his constituents at a time when they needed him the most.

“He’s still a traitor,” she says.

In a national context, Ocasio-Cortez’s victory was an exception. She was the first and to date only primary challenger to defeat a Democratic incumbent in a federal race this year. But in New York her victory was only the latest outgrowth of years of frustration with the state’s dysfunctional and corruption-riddled political establishment. New York may be the nation’s second-biggest blue state, but Albany has been a place where progressive policy goes to die and Democratic lawmakers go to jail. The result was that when progressives woke up in November 2016 to the reality of a Trump presidency, they didn’t just get mad at Republicans—they got angry at a state government they felt had let them down. Newly energized activists, exasperated with everything from the signal system on the subway to rent hikes and a failure to sufficiently safeguard reproductive rights, have increasingly trained their ire on fellow Democrats—people like Peralta; Gov. Andrew Cuomo; and the Queens Democratic Party boss, Crowley.

What’s happening in New York in some ways reflects the larger struggle playing out within the Democratic Party, in which progressive insurgents frustrated with the pace of change have taken the fight to lawmakers they believe are holding the party back.

But nowhere is that frustration more pronounced or more concentrated than in Trump’s backyard, and Ocasio-Cortez’s home turf, an overwhelmingly Democratic district that’s home to three of the eight renegade state senators who composed the IDC. Ocasio-Cortez’s win was powered, in part, by the support of anti-IDC activists, and she slammed the group at town halls and in interviews throughout the campaign. Days after her primary victory, she marched alongside Ramos at an immigrant rights parade in Queens and used her email list to recruit volunteers for another challenger in the Bronx. Now that her race is effectively over—her election in November is more or less a formality—Ocasio-Cortez is using her new cachet to bolster like-minded challengers to the Democratic establishment.

The IDC was able to exist and thrive for seven years in New York in part because betrayal and corruption were already the lifeblood of New York politics.

Before Peralta was a “turncoat,” he was in Ramos’ shoes—the progressive upstart running against an incumbent who had defected from the party. In his case, it was Hiram Monserrate, who in 2008, after Democrats had picked up a one-seat majority in the Senate for the first time in 43 years, plotted with three other Democrats, Pedro Espada Jr., Carl Kruger, and Rubén Díaz Sr., to throw the control of the chamber back to the Republicans unless certain demands were met. Referring to themselves as “the four amigos,” the breakaway faction publicly said their concern was the lack of Latino representation in New York government, but they returned to the Democratic fold only after securing more legislative power for themselves.

The next summer, they did it again. In the middle of session, Monserrate and Espada defected to support Republican Sen. Dean Skelos as majority leader. The coup effectively shut down Albany—Espada procured a key to the locked chamber, only to find that accessing pending bills required a different key he didn’t have—and it ended only after Democrats agreed to make Espada majority leader if he came back.

“The IDC has co-opted the state,” says Alexandria Ocasio-Cortez.

Things went downhill from there. Monserrate was expelled from the chamber in 2010 after he was convicted of assaulting his girlfriend, but he ran for reelection anyway, prompting the challenge from Peralta. Monserrate lost and subsequently pleaded guilty to mail fraud charges. Espada was later convicted of embezzlement; Kruger pleaded guilty to federal bribery charges; and Skelos—whose Republican predecessor as majority leader, Joseph Bruno, was later convicted on federal corruption charges—would eventually be convicted of bribery and extortion as well. Díaz, the only one of the bunch who was never charged with any crime, left the Senate to serve on the New York City Council.

No sooner did the Four Amigos disappear than the IDC emerged to take their place. In 2011, four Democrats—led by the party’s former top strategist, Sen. Jeffrey Klein—formed their own caucus and reached a power-sharing agreement with the Republicans. (A short-lived fifth member, Malcolm Smith, was later convicted on federal corruption charges for, strangely, attempting to bribe his way onto the New York mayoral ballot as a Republican.) After abandoning an earlier promise to rejoin the Democratic caucus, the IDC kept its grip on power for four years and added more members, including Peralta, following the 2016 elections to bring their number to eight—six of whom represent parts of New York City.

Complicating things even further, a ninth New York Democrat has independently caucused with the Senate Republicans since being elected in 2012 but has nothing to do with the IDC and has resisted overtures to caucus with the Democrats. To IDC members such as Peralta, this was one justification for staying put—even if they left, Republicans might still run the show.

Even the CliffsNotes version of the New York Senate is a little convoluted. “One of the great difficulties of challenging the IDC—and I really think we’ve passed the tipping point now—has not been that people find their behavior justifiable; it’s that they found it confusing,” says Zephyr Teachout, a Fordham law professor and IDC critic who is running for attorney general.

“I mean in 2014, if you said ‘IDC,’ they thought it was a cable company or something.”

But after the 2016 election, activists began to see state and local politics as a first line of defense against what was happening in Washington, and they didn’t like what they found when they took a closer look. Illinois had a DREAM Act. Utah—Utah!—had passed a gender-expression nondiscrimination act. Nine states had codified Roe v. Wade and places such as California were forging ahead on single-payer health care plans. Meanwhile, New York’s voting laws were so bad North Carolina cited them in defense of its own racially discriminatory statutes.

“Under Obama things felt okay, like it would be nice to have Democratic control of the New York state Senate, but things felt okay to people,” says Susan Kang, a political science professor at John Jay College. “The election of Trump changed that.”

Kang’s story was typical of the new wave of anti-IDC activists. Although understanding politics is her job, she’d had only a passing grasp of what was happening in Albany. But she started to study up. After Peralta, her state senator, joined the IDC, she sent out an email to a listserv of moms in her neighborhood that had formed after the election—and placed an angry phone call to Peralta’s office, demanding a meeting. When Peralta finally held a town hall, activists packed the building, chanting “traitor” as he struggled to be heard. Some constituents, unable to fit inside the community center, banged on the windows outside.

“One of the great difficulties of challenging the IDC—and I really think we’ve passed the tipping point now—has not been that people find their behavior justifiable; it’s that they found it confusing,” says Zephyr Teachout.

Unlike the Four Amigos, IDC senators argue that their decision was simply pragmatic—if you can’t beat ’em, join ’em. At the town hall, Peralta argued that aligning with the Republicans would give him and his colleagues leverage to better secure passage of bills like the DREAM Act and the New York Reproductive Health Act. Even after the legislative session came and went with little progress on those issues, Peralta and his colleagues argue that what they got out of it was still better than what they would have gotten in the minority.

“Senator Peralta is proud of his record of achievement in the Senate, including the strongest paid family leave program in the country, $15 million in funding for immigrant legal defense, and a $15 minimum wage,” Peralta’s spokesman, Thomas Musich, said in a statement. “While he was fighting for his constituents on these issues Ms. Ramos was nowhere to be found. He looks forward to achieving even more with a Democratic majority in 2019.”

Activists weren’t convinced. Newly formed groups including Empire State Indivisible and Kang’s No IDC NYC began holding teach-ins to explain the inner workings of Albany, protesting outside Senate offices, and phone-banking. They held empty-chair town halls, much like the ones more nationally focused Indivisible groups convened to shame members of Congress. Teachout held events across the city with a comedy group to explain how the IDC worked, and she recorded a short video walking voters through the backstory. So did Sopranos star Edie Falco:

It was an easy issue for Ocasio-Cortez, whose district is home to three IDC senators, including Peralta and the former IDC chairman, Klein. (In January, Klein was accused of sexual misconduct by a former Senate staffer—a charge he denies.) The IDC fit easily into her critique of the Democratic Party as a boys’ club beholden to corporate interests, and in particular, real estate developers. “The IDC has co-opted the state,” Ocasio-Cortez told me last fall, as her campaign was ramping up. As Crowley, in his role as a party boss, was trying to lure the caucus members back—he would eventually endorse Peralta—she tweeted that every member of the group needed to go.

By December 2017, Cuomo, after years of insisting that he didn’t care which party controlled the Legislature—he had even campaigned for two Republican senators when control of the chamber was up for grabs in 2012—was eager to negotiate a peace deal with the IDC and secured a promise that they’d return to the fold if Democrats picked up two state Senate seats in upcoming special elections. The IDC dissolved in April, even before the special elections (but, perhaps not coincidentally, just after actress-turned-activist Cynthia Nixon launched her campaign against Cuomo by specifically invoking the governor’s role in coddling the breakaway faction), and Cuomo soon attended a Manhattan fundraiser to raise money for the IDC members’ reelection fights. By that point Ramos and a slate of candidates had all stepped up to challenge the IDC senators, and the backlash had reached a point of no return.

The 33-year-old Ramos is a natural ally of Ocasio-Cortez.* She entered the race last fall after two years in Mayor Bill de Blasio’s press office and a previous stint in organized labor. She brandishes her New Yorker credentials on the stump like it’s a contest, telling voters she’s a renter who’s never had a driver’s license and is running for office, in part, because of a scarring, hourslong delay she experienced last year on the 7 train.

Queens generally, and the 13th Senate District especially, is among the most diverse places in the world and Ramos, the daughter of Colombian immigrants, believes that diversity lends a moral imperative to her politics. She and Ocasio-Cortez were among the first candidates in America to call for abolishing the Immigration and Customs Enforcement agency, and she frequently notes that Peralta’s defection to the IDC came the same week the president announced his travel ban—instead of beating Republicans, he joined them.

At her office opening in Jackson Heights in March, in a third-floor walkup sandwiched between a Nepalese wholesaler and a travel agency that specializes in the hajj, supporters noshed on empanadas, bagels, and samosas, as Ramos, clutching a balloon handed to her by her young son, rattled off a list of ways in which the district was getting screwed by Albany—an underfunded public transit system; a $45 million shortfall for public schools; and a stalled push for renter protections—and launched into another jab at Peralta.

“There’s only two kinds of state senators—those who vote for [Democrat] Andrea Stewart-Cousins as their leader and those who vote for John Flanagan, a Trump Republican from Long Island,” she said. “That’s who he voted for. I would never do that, and I would never betray my neighbors that way. I would never betray my family that way.”

Ramos was a long shot when she entered the race, but six months later it doesn’t seem quite so crazy. Two days after Ocasio-Cortez’s victory, the speaker of the New York City council endorsed Ramos and three other candidates challenging ex-IDC members. Then Ramos picked up the endorsement of a state assemblywoman whose district overlaps with hers. A few days later, Nixon dropped by a public library in Jackson Heights to announce her support. Last week, Rep. Carolyn Maloney, whose district includes part of Queens and who just survived a surprisingly competitive primary herself, endorsed Ramos. Suddenly, bucking the Democratic establishment didn’t seem so dangerous.

Other candidates felt a boost too. Kang says the day after the June primary was her group’s best fundraising day ever. And about a week after the election, after months of pressure from activists begging him to enter the race, the city’s ex-comptroller announced he would challenge another former IDC senator who represents part of Ocasio-Cortez’s district.

And Ocasio-Cortez’s army of volunteers is waiting in the wings. Facing only nominal Republican opposition in the fall in one of America’s bluest House districts, Ocasio-Cortez has time on her hands and newfound political capital to spend, and she’s made clear one way she intends to spend it—by backing a new slate of ideologically aligned candidates in her own backyard. After her primary, Ocasio-Cortez sent out a call for volunteers to gather petitions and go canvassing for a slate of progressive Democrats who, like her, were mounting insurgent campaigns against the state’s entrenched establishment. Among them were Nixon; Teachout, an early ringleader of the anti-IDC brigade and a longtime critic of Albany corruption; and two state Senate candidates, including Klein’s challenger in the Bronx, Alessandra Biaggi.

“I cannot overstate the importance of Alexandria’s victory,” Teachout says.

In her campaign, the effect was immediate. Within a few days of Ocasio-Cortez’s ask last month, hundreds of new volunteers had signed up to gather signatures to put Teachout on the September ballot, and their joint appearance a few days later, in the shadow of the Wall Street bull, was a media frenzy. (At their first press conference together, three months earlier, just one reporter showed up.)

When I visited Teachout’s Spanish Harlem headquarters in early July, the walls of the converted doctor’s office were adorned not just with her own bluish green campaign signs but with a handwritten motivational quote, put up a few days earlier—“there is nothing radical about moral clarity in 2018.” There was no citation, but it wasn’t needed; it was a line from Ocasio-Cortez’s victory speech.

Correction: An earlier version of this article misstated Ramos’ age.