media captionWhat's at stake in the NYC mayoral election? New Yorkers explain.

Former presidential candidate Andrew Yang has dropped out of the race to become the Democratic candidate for New York City mayor after coming fourth in the primary election.

Brooklyn borough president Eric Adams, an ex-police captain, is leading.

For the first time a ranked-choice system is being used and the result is unlikely to be known for several weeks.

New York is a Democratic stronghold and the party's candidate is likely to be its next mayor after November's vote.

The mayor will oversee the city's recovery from the coronavirus pandemic. Most restrictions have now been lifted, but the city has seen a rise in shootings and murders meaning public safety has dominated the campaign.

  • Where will the Yang Gang go next?
  • Once the future, US now captive to its past

Mr Yang – a tech entrepreneur who attracted a devoted following during his bid to be the Democratic presidential candidate in the 2020 election – had been the frontrunner to become the party's New York candidate.

But he conceded after early results put him a distant fourth.

"I am a numbers guy. And I am not going to be mayor of New York City based on the numbers that have come in tonight," the 46-year-old told supporters.

image copyrightEPAimage captionMr Yang has pulled out after coming fourth

The winning Democrat will face Republican candidate Curtis Sliwa, the founder of the Guardian Angels, a volunteer organisation that carries out unarmed anti-crime patrols. He beat businessman Fernando Mateo.

Who are the Democratic candidates?

Eric Adams, a centrist candidate, was the first choice of more than 30% of those who voted in person or during the early voting period.

In second place was Maya Wiley, a lawyer who previously served as counsel to the outgoing Mayor Bill de Blasio. She is a left-wing progressive candidate who has received support from rising Democratic star Alexandria Ocasio-Cortez.

image copyrightReutersimage captionMr Adams has put fighting crime at the centre of his campaign

Kathryn Garcia, who was head of New York's sanitation department, is in third place with nearly 20%.

Both Ms Wiley and Ms Garcia would be New York's first female mayor; Ms Wiley and Mr Adams would be its second black mayor.

"Tonight we took a huge step forward," Mr Adams was quoted as saying by the New York Times. "As a city we're going to turn our pain into purpose. We're going to become a safe, affordable, fair city."

How does the voting system work?

Mr Adams is so far well short of the 50% of first-choice votes needed for him to be the outright winner under the ranked preference voting system.

The ranked preference voting system works by eliminating the candidate who comes last and redistributing the ballots cast for them to voters' second choice candidate. This process is repeated until a candidate passes the 50% threshold. A final result may not be known until July.

image copyrightEPAimage captionMs Wiley has been endorsed by Alexandria Ocasio-Cortez

Nearly 800,000 votes have been counted from more than 80% of voting precincts. The provisional count shows Mr Adams in the lead in all boroughs except Manhattan, where Ms Garcia is leading.

What are the key issues?

Public safety has dominated debate in the campaign. Unemployment, homelessness, murders and shootings have all surged during the pandemic.

New York saw murders rise by 14% and shootings by 50% in the first three months of 2021 compared to the same period last year. Those statistics mirror a surge in crime across US cities more generally.

Meanwhile, attacks on Asian Americans and the murder of George Floyd have also highlighted racial inequality in the city.

Some wealthy New Yorkers have moved out of the city, and the new mayor will face projected budget shortfalls of several billion dollars in the coming years.

image copyrightReutersimage captionThe winning Democrat will face Republican candidate Curtis Sliwa

Mr Adams has put public safety at the forefront of his campaign. He has been critical of the city's police but says they are vital to the fight against crime and insecurity.

"The debate around policing has been reduced to a false choice: You are either with police, or you are against them," he said on his campaign website. "That is simply wrong because we are all for safety. We need the NYPD – we just need them to be better."