“We are proud of all the endorsements we have gotten, but this is a big deal,” Ms. Cabán, who previously worked as a public defender, said. “Alexandria Ocasio-Cortez is a progressive champion and she’s been an inspiration for me. It shows that we are building a national, grass-roots progressive movement.”

Ms. Ocasio-Cortez’s endorsement was one of the most sought after among progressive candidates in the race to replace the longtime district attorney, Richard A. Brown, who died May 4 from complications of Parkinson’s disease. Mr. Brown had previously announced he would resign on June 1, the 28th anniversary of his taking the office.

Ms. Ocasio-Cortez, who has more than 4 million followers on Twitter, is expected to send an email to her supporters this week announcing her endorsement and asking them to donate to Ms. Cabán.

“Instead of criminalizing poverty, we’re going to dedicate resources toward prosecuting abusive landlords,” Ms. Ocasio-Cortez said. “Instead of targeting people who use marijuana, we can go after the drug companies that took advantage of working-class folks for profit.”

She added: “We can end broken-windows policing and rebuild the relationship between our communities, and the justice system that’s supposed to work for us. We can end cash bail, so that the rich and poor are held equal in the eyes of the law.”

Ms. Cabán could not be more ideologically different than Mr. Brown.

She is in favor of closing Rikers Island, but she does not support the plan to build new borough-based jails. She is in favor of ending the prosecution of drug use and supports fully decriminalizing prostitution, including for the clients. She is also a proponent of ending cash bail for all crimes.

Ms. Cabán has received endorsements from the Democratic Socialists of America, VOCAL-NY Action Fund, Real Justice PAC and the Working Families Party, among others.