Queens district attorney candidate Tiffany Cabán conceded defeat Tuesday night — six weeks after the Democratic primary election that pitted her against the establishment-backed Queens Borough President Melinda Katz.

“We terrified the Democratic establishment,” Cabán told her supporters at a party in Astoria.

“We showed [that] you can run on a boldly decarceral platform,” she added referring to her criminal justice reforms. “You don’t have to play by the old rules.”

In a back-and-forth race that saw both candidates declare victory, the insurgent lawyer fought to the very end challenging dozens of invalidated affidavit ballots in court that she said were improperly excluded.

But after several attempts to claw back — including at a judicial hearing earlier Tuesday — she bowed out after it became clear she’d be unable to erase the 60-vote gap separating her and Katz.

“There’s still so, so much work to be done here in Queens — and you better believe I’m going to keep fighting,” Cabán said.

The Rep. Alexandria Ocasio-Cortez-backed candidate shocked the city on June 25 when she appeared to beat Katz, a veteran Queens politician, by 1,100 votes on primary night.

But the tables flipped when the Board of Elections tallied the absentee ballots and many of the provisionally cast ballots, giving Katz the lead.

Last Monday, the Board of Elections declared Katz the victor.

The certified results showed Katz winning 34,920 votes, a razor-thin edge over Cabán’s 34,860.

Katz now becomes the heavy favorite to win the job in the November general election in the increasingly left-leaning borough.