NEW YORK — New York's Democratic primary for mayor was left unsettled on Tuesday night, with Brooklyn Borough President Eric Adams, a former police captain, appearing to have the advantage in the city's first ranked-choice election.

Adams, 60, who would be just the second Black mayor of New York, emerged from a field that spent the last six months debating the city's rising crime and the difficulty of building back after the pandemic.

Final results are not expected until July 12, given both the city's rickety election system and new ballots that allow voters to rank up to five candidates, allotting their choices until one candidate reaches a majority.

While no winner can be declared until the end of a multipart count, the Adams campaign had suggested that it would amount to voter suppression if the candidate who had the most first-choice votes did not become mayor.

Adams stopped short of declaring victory on Tuesday, telling a crowd in Brooklyn that the vote count would continue, "but New York City said our first choice was Eric Adams."

Two other candidates trailed Adams in first-choice votes but hoped to prevail in the final allocation of ballots: civil rights attorney Maya Wiley and former city sanitation commissioner Kathryn Garcia. Garcia told supporters she was relying on the ranked-choice process. "This is not just about the ones," she said. "It's going to be about the twos and threes."

Entrepreneur Andrew Yang conceded in the New York City Democratic mayoral primary during a campaign event on June 22. (Yossi Schlussel via Storyful)

In a distant fourth was 2020 presidential candidate Andrew Yang. He conceded the race on Tuesday night, saying he had no path to victory and thanking the voters who thought "politics as usual wasn't working" and took a chance on him.

Republicans, with a two-way race, were not subject to ranked choice. The Associated Press projected talk-show host Curtis Sliwa, a fixture in New York politics, as the winner over businessman Fernando Mateo. Mateo advanced the false claim that President Donald Trump won the 2020 presidential election, while Sliwa did not support Trump.

Adams was the dominant figure in a Democratic race to succeed Mayor Bill de Blasio (D), in which sexual misconduct allegations, a campaign staff revolt and even a debate question about real estate prices knocked other candidates off course.

“New city, new vision, new mind-set,” Adams told voters at a Sunday rally in Inwood, a largely Dominican neighborhood in Manhattan. “We are going to finally end the institutional poverty in our city. We’re going to become a safe, fair, affordable city. We will get the justice we deserve with the safety we need.”

In recent public polls, he charged ahead of Yang, 46, who attacked Adams as a corrupt insider who would not deliver real change.

The city’s ranked-choice voting system allows voters to list up to five candidates in order of preference. No winner will be declared until those preferences are added up and lower-finishing candidates are nixed in a series of tallies until one candidate cracks 50 percent. That will slow down the count, and the city’s Board of Elections is also expecting thousands or tens of thousands of absentee ballots to arrive and be counted after Tuesday, which will delay a final ranking.

No Democratic mayoral candidate had been expected to win an outright majority Tuesday — but because New York City has a Democratic majority, the eventual primary winner is likely to be elected mayor in November.

Also on the ballot were city, borough and other positions, the most prominent of which is Manhattan district attorney. Because that is a county position, it is the sole office that will not be determined by the city’s ranked-choice voting system. The incumbent, Cyrus Vance Jr., who has been leading an investigation of former president Donald Trump, announced earlier this year that he would not seek a fourth term.

Former state prosecutor Alvin Bragg was narrowly ahead of former federal prosecutor and self-funder Tali Farhadian Weinstein. Tahanie Aboushi, who is running as an outsider seeking to rein in the office, was trailing the duo.

In the race for city comptroller, Brad Lander, a liberal city legislator endorsed by Rep. Alexandria Ocasio-Cortez (D-N.Y.), was leading City Council Speaker Corey Johnson, with eight other candidates splitting the rest of the vote.

The new voting system, which replaced the city’s old two-round runoff law, had kept mayoral paths open for Garcia, 51, and Wiley, 57. Both were largely unfamiliar to voters when the primary began, and both emerged as popular second-choice candidates for voters wary of Adams and Yang, whose less liberal views made them attractive to wealthy donors.

Either woman would be the first of her gender to be elected mayor; Yang would have been the first Asian American.

“We recover from crisis,” Wiley said at one of the Democrats’ final pre-primary debates, arguing that the wrong mayor could slant the city’s post-pandemic recovery toward the very rich. “What we have not done, in the past, is recover every last one of us.”

Wiley closed out the race as the Democrat backed most strongly by her party’s left, rising in polls after an endorsement by Ocasio-Cortez.

“Before Alexandria endorsed Maya, I liked Eric Adams. But I follow Ocasio-Cortez,” said Rosa Rodriguez, 65, a Dominican food preparer for a catering business in Jackson Heights, a Queens neighborhood in the congresswoman’s district. Rodriguez wept as she talked about a fire that forced her out of her home, putting her and her mother in temporary hotel housing. “I hope when Maya wins, I will have some place where I live.”

Of the four leading candidates, Wiley was the only one arguing for cuts to the New York Police Department’s budget, while proposing a “New Deal New York” investment of $10 billion to create at least 100,000 jobs. Garcia, boosted by endorsements from the New York Times and the New York Daily News, pitched herself as a nonideological problem-solver who can make the city safer and more affordable.

“I want people to stay here. I want to stay here,” Garcia said in a recent interview. “I want people to move here. I want people to think: I have the most opportunity, regardless of my field, if I come to New York.”

No candidate had consolidated the field as de Blasio did eight years ago, building a coalition of Black voters, White liberals and moderates outside Manhattan. On Saturday, Yang and Garcia rallied together; Adams’s campaign labeled that the “Yang Gang-Up” and released statements from prominent Black supporters who accused a White woman and an Asian man of trying to suppress Black progress.

“Latino and Black New Yorkers did not organize and fight for generations so that they could finally put a working-class person of color in Gracie Mansion, just to then have their victory taken from them by a backroom deal,” said Bronx Borough President Ruben Diaz Jr., whose decision not to run for mayor created an opportunity for Adams.

Nine other Democrats shared space on the ballot, from fringe candidates such as Paperboy Love Prince — who campaigns in a spray-painted “love tank” — to New York City Comptroller Scott Stringer, a journeyman liberal who lost many of his endorsements after a volunteer from one of his past campaigns accused him of sexual misconduct. Dianne Morales, a nonprofit chief executive who ran to the left of the field, faded after an embarrassing dispute over staff pay that ended with her own former campaign workers protesting her, with some endorsing Wiley.

More moderate candidates also got lost in the crowd. Former Citi executive Ray McGuire had endorsements from Patrick Ewing, Jay-Z and Spike Lee, but his finance background left Democrats cold.

Former housing and urban development secretary Shaun Donovan, whose father poured money into a supportive super PAC, touted his work for President Barack Obama, but stumbled when the New York Times editorial board asked candidates how much the average home sold for in Brooklyn. Both Donovan and McGuire understated the cost by about 90 percent, although Donovan said he had misunderstood the question.

The accusations against Stringer had a bigger impact on the race, sending left-wing endorsers scattering, with not all of them getting behind Wiley — while unions loyal to Stringer kept spending on his behalf.

The dispersal of votes to so many challengers accrued to Adams’s benefit. In polling that gamed out the multiple stages of a ranked-choice vote, Adams consistently came out on top, benefiting from the support of Black voters and moderates. He has called for restoring a police crime unit scrapped after last summer’s civil rights protests, and he has argued that he knows both policing and discrimination against Black New Yorkers better than anyone else running.

Adams’s rivals argue that he evaded the sort of vetting that weakened candidates such as Stringer and Yang. In the final days of the race, Adams took reporters on a tour of a New York apartment, claiming it was his main residence, although he admitted that he had done some virtual campaigning from a home he owns in New Jersey. After former mayor Rudolph W. Giuliani said that Adams gave him “hope,” in a year when Republicans had not recruited a credible candidate, Adams accused him of “sabotage” and rejected his support.

By Sunday evening, when the early-voting period closed, nearly 192,000 New Yorkers had cast ballots; the majority of those votes came from Manhattan and Brooklyn, in line with recent primary trends. More than 200,000 voters requested absentee ballots, the majority of which had not been returned by Monday. Nearly 700,000 Democrats turned out in the competitive 2013 primary before the state’s governing Democrats expanded absentee and early voting for this mayoral contest.

Some Democrats skipped the early-voting period but were ready to make a decision on Tuesday. “I like him 100 percent,” Olga Quinones, 62, said of Adams. A Dominican American who lives on her disability benefits, Quinones met her favorite candidate as he danced and played dominoes with Spanish-speaking voters on Sunday before holding a news conference decrying gun violence.

“He’s going to fight the crime,” she said. “He was a police officer. He has experience.”

The ranked-choice voting system didn’t matter to her; she planned to mark her ballot for Adams and no one else.

Weigel reported from Washington.