QUEENS -- Tiffany Cabán, a 31-year-old public defender who says the criminal justice system is rigged against the poor, declared victory in an extremely close Democratic primary for Queens District Attorney Tuesday night, but it may be days before official results are in.

Appearing before a raucous crowd of supporters on Tuesday night, Cabán said, "They said we could not win. But we did it y'all."

Cabán, the candidate favored by left-wing Democrats in New York City, held a small lead over Queens Borough President Melinda Katz, a seasoned politician who had the backing of the state's Democratic Party establishment.

But it will be several days before thousands of mailed-in ballots are opened and counted.

Katz, who suggested there could be a recount, told supporters just before 11 p.m. that "there's a lot more days" before the results will be known.

Cabán is endorsed by two presidential contenders, Sens. Elizabeth Warren of Massachusetts and Bernie Sanders of Vermont, as well as U.S. Rep. Alexandria Ocasio-Cortez, the newcomer whose primary defeat of a longtime incumbent last year electrified the party's left wing.

"I am so incredibly proud of @CabanForQueens - and EVERY single person who showed up for this election today," Ocasio-Cortez wrote in a tweet. "When people come together, we can beat big money in elections. People power is no fluke."

I am so incredibly proud of @CabanForQueens - and EVERY single person who showed up for this election today. No matter how this ends, you all have stunned NY politics tonight. When people come together, we can beat big money in elections. People power is no fluke. https://t.co/hsJx7p3REN — Alexandria Ocasio-Cortez (@AOC) June 26, 2019

It's a tight race between Cabán and Katz, who had the backing of state and county party leaders like New York Gov. Andrew Cuomo as well as a host of unions. Katz is a veteran politician, having served in the state Assembly from 1994 to 1999 and on the City Council from 2002 to 2009.

Four other candidates trailed far behind in the vote tallies.

If victorious, Cabán would be favored to win the November general election to succeed longtime District Attorney Richard Brown. He died last month at age 86.

She would be the first woman to serve as Queens district attorney if elected in November.

Tiffany Cabán took on virtually the entire political establishment and built a grassroots movement. This is a victory for working people everywhere who are fighting for real political change and demanding we end cash bail, mass incarceration and the failed war on drugs. https://t.co/BkyYMzCfxj — Bernie Sanders (@BernieSanders) June 26, 2019

I am so incredibly proud of @CabanForQueens - and EVERY single person who showed up for this election today. No matter how this ends, you all have stunned NY politics tonight. When people come together, we can beat big money in elections. People power is no fluke. https://t.co/hsJx7p3REN — Alexandria Ocasio-Cortez (@AOC) June 26, 2019

The Associated Press contributed to this report.