The Democratic primary for district attorney in Queens, a race that drew nationwide attention, was thrown deep into uncertainty on Wednesday after a count of paper ballots flipped the primary-night result.
Tiffany Cabán, a 31-year-old public defender, saw her almost 1,100-vote lead evaporate, with Melinda Katz, the Queens borough president, edging out to a 20-vote lead.
The tight margin will automatically trigger a recount, according to Valerie Vazquez-Diaz, a spokeswoman for the New York City Board of Elections. It also spurred accusations from Ms. Cabán’s side that elections officials improperly invalidated more than 2,000 affidavit ballots before the paper ballots were counted.
“We are going to fight to make sure every valid vote is counted and every voter has a voice,” said Bill Lipton, the New York director of the Working Families Party, which supported Ms. Cabán. “And when all the votes are counted, we are confident Tiffany Cabán will be the next Queens district attorney.”
The primary race was cast as a battle between the traditional power bases in Queens and the progressive forces that propelled Representative Alexandria Ocasio-Cortez to her primary victory in New York last year. Ms. Katz had the backing of unions and local political leaders, while Ms. Cabán received support from prominent members of Congress, including Ms. Ocasio-Cortez.
Ms. Katz is ahead by 20 votes, 34,898 to 34,878, according to lawyers representing her. Jerry H. Goldfeder, a veteran election lawyer representing Ms. Cabán, agreed that Ms. Katz was now ahead by 20 votes.
The new vote total meant that Ms. Katz drew twice as many votes from the paper ballots as Ms. Cabán did.
Mr. Goldfeder said he intended to challenge the decision to invalidate all but 487 of the 2,816 affidavit ballots cast. Election officials said they had determined that the ballots, used when a voter’s name is not listed at the polling place, were invalid or had been cast by ineligible voters.
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.
Before the paper ballots were counted, Ms. Warren even used Twitter to congratulate Ms. Cabán on her apparent victory in the primary.
If Ms. Katz’s slim lead holds up, it would be a victory for the power bases that typically dictate election results in Queens; traditionally, party leaders back the Democratic incumbent or an anointed successor. The last contested Democratic primary occurred in 1955.
Mr. Goldfeder said he was “optimistic” that Ms. Cabán could still win the primary because of the more than 2,000 affidavits that were invalidated.
“We have identified a goodly number that should have been counted,” he said.
Under a manual recount, there is also the possibility that some ballots that were initially invalidated — possibly because voters failed to properly fill in the bubble next to their chosen candidate — would be validated and added to the vote total.
Whoever wins will be an overwhelming favorite in November’s general election against the Republican candidate, Daniel Kogan. No Republican has been elected to the office since Dana Wallace’s win in 1920.
The Democratic primary showed that voters in Queens were willing to entertain major change to the borough’s criminal justice system. All six candidates had backed proposals to get rid of bail for low-level offenses, move away from prosecuting sex workers and form a conviction-integrity unit.