New York City mayor Bill de Blasio has ended his campaign for the 2020 Democratic presidential nomination.

He announced his decision in an MSNBC interview after struggling to gain traction in a sprawling field of Democrats seeking the presidency.

“I feel like I’ve contributed all I can to this primary election, and it’s clearly not my time,” he said.

“So I’m going to end my presidential campaign, continue my work as mayor of New York City, and I’m going to keep speaking up for working people and for a Democratic Party that stands for working people.”

President Donald Trump tweeted: “Oh no, really big political news, perhaps the biggest story in years! Part time Mayor of New York City, @BilldeBlasio, who was polling at a solid ZERO but had tremendous room for growth, has shocking dropped out of the Presidential race. NYC is devastated, he’s coming home!”

Mr de Blasio joins New York senator Kirsten Gillibrand, Washington senator Jay Inslee, Massachusetts representative Seth Moulton, former Colorado governor John Hickenlooper and California representative Eric Swallwell, who have all left the Democratic primary race.

He did not throw his support behind any candidate but said he would support the eventual Democratic nominee “with energy”.

Mr de Blasio launched his bid in May but his campaign largely failed to take off.

He never achieved higher than 1% in a national poll and was ridiculed in the media, most recently in a Washington Post story headlined “Bill de Blasio’s presidential campaign has burned down, fallen over and sunk into a swamp”.

He qualified for the first two rounds of debates but failed to make the September debate stage and appeared unlikely to qualify for the October debates.

He struggled to achieve the breakout moment he needed to stand out in the crowded Democratic field.

After a strong performance in the first round of debates in June he blundered in a campaign appearance in Miami by quoting Che Guevara. He said he did not know that the slogan “Hasta la victoria siempre!” was associated with Guevara, a leader of the Cuban Revolution who is reviled by much of Miami’s Cuban population.

Mr de Blasio boasted of his administration’s record on police reform but was followed around on the campaign trail by protesters from the city’s largest police union and by hecklers demanding that he fire the officers involved in the 2014 death of Eric Garner on Staten Island.

The protests did not end after the August 19 firing of Officer Daniel Pantaleo, who placed Mr Garner in the chokehold that contributed to his death.

An activist attending Mr de Blasio’s August 25 CNN town hall meeting shouted: “What about Lieutenant Bannon? What about Officer Ramos? What about other officers?” referring to officers who were also present during Mr Garner’s arrest.

The mayor had announced his presidential run by heading to the Statue of Liberty, where he said the country was in an “identity crisis” around immigration, which he called “the founding and unifying element of the American experience”.

“We are figuring out who we are,” he said then. “There are American values we need to return to and fight for in order to achieve our greatest potential.”

On his campaign’s first day, he dived into an insult match with Mr Trump.

“He’s a con artist. I know his tricks. I know his playbook,” the mayor said.

Mr Trump tweeted at the time that Mr de Blasio was “considered the worst mayor in the US”.

The Republican president said: “He is a JOKE, but if you like high taxes & crime, he’s your man. NYC HATES HIM!”

When Mr de Blasio took office in 2014, he seemed briefly poised to become a leading voice for an emerging left wing of the Democratic Party. His central message was fighting income inequality, a theme he hit in the video announcing his presidential candidacy.

“There’s plenty of money in this world. There’s plenty of money in this country. It’s just in the wrong hands,” he said.

But liberals’ enthusiasm for him faded during his first term as mayor, partly because of political missteps at home and the emergence of bigger names elsewhere.