UPDATE: The Associated Press called this race for Dan Goldman at 12:39 a.m. Click here for a link to the updated story on the race.

Dan Goldman, a former prosecutor who campaigned on a promise to oppose right-wing Republicans and former President Donald Trump, held a slight lead over Yuh-Line Niou, a left-leaning state Manhattan assemblymember backed by the Working Families Party, in the race for an open seat in the 10th Congressional District. But the margin of victory meant that the race was too close to call.

As of 11:20 p.m. Tuesday, Goldman had 16,686 out of 65,107 votes cast, or 25.63%, according to unofficial voting results, over Niou's 15,380 votes, or 23.62%. Under New York’s election rules, a manual recount is triggered in non-statewide races if the margin of victory is less than half a percent of the total number of ballots cast in the contest. As of Tuesday, there were over 21,000 absentee ballots mailed out to constituents, of which over 7,000 are currently considered valid.

Nevertheless, Goldman — a 46-year-old first-time candidate who poured $4 million of his own money into the race — declared himself the winner on Tuesday night at his election party in Manhattan.

“While we will appreciate and respect the democratic process and make sure that all the votes are counted, it is quite clear from the way that the results have come in that we have won,” he said, as cheers erupted.

Afterward, Simone Kanter, a spokesperson for the campaign, acknowledged that not all the votes had been counted. But he said the campaign was confident that absentee ballots would be in their favor.

The race was considered among the more suspenseful Democratic primaries in New York that featured a crowded field of competitors. Low turnout and several leading candidates had suggested a tight primary for an open seat representing Lower Manhattan and northwest Brooklyn.

At her election night party in Brooklyn, Niou, a 39-year-old Taiwanese immigrant, said she would not concede until every vote was counted. A crowd of young, energetic supporters burst into cheers when she walked into the party with tears in her eyes as she hugged almost every person she walked by.

"What we did together when I first ran for the state Assembly in 2016, I said I was betting on people, and I said that again in May, when I announced my run for Congress, and from early voting today, we have shown them why betting on people is always the right choice," she said. "I know that tonight’s results aren’t yet what we hoped to hear, but we will not concede until we count every vote."

If elected, she would become only the second Asian American elected to Congress from New York.

Manhattan Councilmember Carlina Rivera, another top candidate in the race, appeared to have conceded in her race as she stood with supporters at her election night party on the Lower East Side, where she grew up.

“I want you to know that I’m going to keep serving you,” Rivera said. “I’m a proud public servant and damnit I’m good at it.”

Polls had shown Goldman, Niou, Rivera and Hudson Valley Rep. Mondaire Jones to be the leading four contenders. Other candidates in the race included Brooklyn state Assemblymember Jo Anne Simon and former Rep. Elizabeth Holtzman.

The heated battle over an open seat in one of the city’s most liberal swaths came about after a contested redistricting process forced the congressional maps to be redrawn, resulting in split primaries in June and August.

While the candidates all considered themselves progressive, they weren't completely in sync with their policy platforms.

On public safety, Goldman positioned himself as a centrist, expressing concerns similar to that of Mayor Eric Adams on whether bail reform has contributed to repeat offenders.

He appeared to voice support for a ban on late stage abortions during an interview with the conservative Jewish outlet Hamodia, but immediately walked back his comments, saying he was “unequivocally” in support of a woman’s right to an abortion.

But ultimately, it was the threat of Trump that shaped the race in favor of Goldman, who served as one of the lead prosecutors during the latter’s first impeachment trial.

In the final days, the former president inserted himself into the race by issuing a mock endorsement of Goldman that some of his rivals sought to use to their advantage.

Goldman, however, accused Trump of trying to meddle in the election.

An heir to the Levi Strauss clothing fortune, Goldman was considered a serious contender from the start given his financial resources and broad name recognition as an MSNBC contributor. But it was not until he unexpectedly won the endorsement of the New York Times editorial board that Goldman catapulted to frontrunner status.

Niou, whose Assembly district includes large portions of Lower Manhattan, campaigned as a progressive Democrat un-beholden to moneyed interests. As one of the state lawmakers who vehemently spoke out against then Gov. Andrew Cuomo, she also promised to be unflinching when it came to criticizing those in her own party.

She also positioned herself as the most left-leaning candidate. On public safety, she argued that crime was rooted in poverty and that investing more in social programs was the right solution. She was also the only candidate that sought to abolish the Immigration and Customs enforcement agency.

Her refusal to denounce the Boycott, Divestment and Sanctions (BDS) movement targeting Israel was seen as potentially alienating some of the district’s Jewish voters.

More than a dozen candidates initially threw their hat into the ring. The most well-known candidate, former Mayor Bill de Blasio, dropped out of the race last month due to a lack of sufficient support.

Jake Offenhartz and Catalina Gonella contributed reporting.

Correction: This story has been updated with the correct percentage of Yuh-Line Niou's share of the vote at 23.62%.