The Tiffany Cabán-Melinda Katz Democratic primary battle for Queens district attorney is headed for a recount — and a potential court fight.

After a daylong manual recount of thousands of paper ballots, Democratic Party favorite Katz pulled ahead of insurgent candidate Cabán by 20 votes Wednesday, according to the city Board of Elections.

That marked a huge turnaround for the Queens borough president, who came into the paper ballot tally 1,199 votes behind Cabán, the nominal winner of the June 25 primary.

Katz declared victory Wednesday night, even as she tacitly acknowledged her battle with Cabán is far from over.

“I am proud to have been chosen as the Democratic nominee for Queens district attorney,” Katz said in a statement. “We know that these numbers can and will be subject to recount, and there may be legal challenges, but what matters most is the will of Queens voters.”

Cabán’s team, meanwhile, vowed to fight to the end.

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

A Stunning Turn of Events

The pre-holiday fireworks marked the latest chapter in the contest pitting Katz, a former City Council member and Democratic Party stalwart, against Cabán, an until recently unknown public defender who earned the backing of Queens machine-slayer Alexandria Ocasio-Cortez.

“If the count holds, it would be an unbelievable comeback and a truly miraculous victory for Melinda — perhaps one of the biggest come-from-behind victories in state history,” said veteran political consultant George Arzt.

But Arzt and other seasoned observers weren’t calling the contest just yet. The slim margin triggered a full manual recount, which is expected to take about two weeks.

Meanwhile, Cabán’s team huddled in a war room reviewing some 2,000 invalidated affidavit ballots, with plans to fight for every vote, said campaign attorney Renée Paradis. The day had started with some 6,300 absentee and affidavit ballots to be counted.

Attorneys for both teams will meet with city Board of Election staff Friday morning at the Queens BOE office in Forest Hills to determine the next steps for the manual recount.

The winner ostensibly will go up against GOP nominee Daniel Kogan, an Ozone-Park based attorney, in the Nov. 5 general election. But Kogan has said he doesn’t plan to run a vigorous campaign. Some Queens Republicans are looking to replace him — possibly with Greg Lasak, the former judge and prosecutor who placed third in the crowded Democratic primary.

The Democratic primary to replace the late, longtime Queens DA Richard Brown drew 80,000 of 760,000 active Democratic voters in the county. It followed last year’s primary loss of Queens party boss Joe Crowley to Ocasio-Cortez — an upset that shook up the political status quo locally and nationally.

Sign up for “THE CITY Scoop,” our daily newsletter where we send you stories like this first thing in the morning.

Want to republish this story? See our republication guidelines.