Basil A. Smikle, the executive director of the state Democratic Party during that primary, said he noticed then how the left flank of the party was becoming far better at mobilizing and organizing voters around issues that once seemed too liberal for the party’s base.

“The response to me was more of an open question about how strong they actually were among the electorate,” said Mr. Smikle, now a lecturer on politics and public policy at the City University of New York.

Two years later, the seismic intraparty political shifts began. First came Ms. Ocasio-Cortez’s victory over Mr. Crowley; a few months later, most of the Independent Democratic Conference, a group of Democratic state senators that worked with Republicans, were swept from office.

That was soon followed by Amazon rescinding its decision to build a campus in Long Island City after progressive activists fought against a plan to provide the company with $3 billion in government incentives.

State Senator Michael Gianaris was one of the leaders of the opposition to Amazon’s plans. He also endorsed Ms. Cabán. “Progressive victories one after another cannot be dismissed as isolated incidents,” he said, adding that the machine “is best advised to come out of denial.”

One of the more notable factors in the race was how it drew national attention: Ms. Ocasio-Cortez and Mr. Sanders, who both identify as Democratic Socialists, endorsed Ms. Cabán, along with Mr. Sanders’s fellow Democratic presidential candidate, Elizabeth Warren.

The endorsements helped Ms. Cabán make up what had been a sizable fund-raising deficit, with many small donations coming from outside New York State.