The Board of Elections would not release any information until the election results were certified but confirmed that there would be a recount. The board has a policy of conducting a manual recount when the victory is by less than 0.5 percent, Ms. Vazquez-Diaz said.

“Queens voters are inspired by Tiffany Cabán’s campaign and her vision for real criminal justice reform,” Ms. Cabán’s spokeswoman, Monica Klein, said in a statement. “If every valid paper ballot vote is counted, we are confident we will prevail.”

On primary night in June, Ms. Cabán declared victory, even as Ms. Katz vowed to fight on. On Wednesday, the roles were reversed.

“We said from the beginning that every vote needs to be counted and that every voter needs to be heard, and now we see clearly why this must always be the case,” Ms. Katz said in a statement issued Wednesday night. “I am honored to be ready to serve as Queens’ next district attorney.”

Ms. Cabán, a first-time candidate, had drawn celebrity support and a wealth of out-of-state donations after running a campaign that was seen as an extension of other criminal justice reformers who have won top prosecutor jobs in places like Boston and Philadelphia. Those prosecutors, Larry Krasner, in Philadelphia, and Rachael Rollins, in Boston, both endorsed her.

Ms. Cabán had also picked up endorsements from Ms. Ocasio-Cortez — they campaigned together two days before the election — and Senators Elizabeth Warren of Massachusetts and Bernie Sanders of Vermont, who are both running for president.