Years of anger at a group of Democratic state senators who had collaborated with Republicans boiled over on Thursday, as primary voters ousted nearly all of them in favor of challengers who had called them traitors and sham progressives.

The losses were not only a resounding upset for the members of the Independent Democratic Conference, who outspent their challengers several times over, but also a sign that the progressive fervor sweeping national politics had hobbled New York’s once-mighty Democratic machine, at least on a local level.

The most high-profile casualty was Senator Jeffrey D. Klein of the Bronx, the former head of the I.D.C. In that role, he was for years one of Albany’s most powerful players, sharing leadership of the chamber with his counterparts in the Republican conference and participating in the state’s secretive budget negotiations.

[What exactly was the I.D.C.? Read our explainer here.]

But on Thursday, he was defeated by Alessandra Biaggi, a lawyer and former aide to Gov. Andrew M. Cuomo, after a campaign in which Ms. Biaggi cornered Mr. Klein into spending more than $2 million, an astonishing sum for a state legislative race. (Cynthia Nixon, in her unsuccessful bid against Mr. Cuomo, spent less.)