Mayor Bill de Blasio finally pulled the plug on his ill-fated presidential bid that failed to gain more than 1 percent support in national polls — but drew plenty of ire from New Yorkers who elected him to run the country’s largest city.

“I feel like I’ve contributed all I can to this primary election and it’s clearly not my time so I’m going to end my presidential campaign,” de Blasio said on “Morning Joe” Friday, over four months after launching his long-shot campaign on May 16.

The 58-year-old — notorious for his tardiness to official city events — said he “started later than I would have liked.”

In an opinion piece for NBC News, de Blasio, the 24th Democrat to jump into the crowded field last spring, said he was going to put his progressive presidential policy ideas to work in New York City.

“I’m going to redouble my efforts to improve the quality of life of everyday New Yorkers, proving that policies like guaranteed paid personal time off can work on a grand scale,” he said, adding that he’ll also “continue implementing universal health care and a Green New Deal in the nation’s largest city.”

De Blasio said he’d stay involved in national politics, though he declined to endorse a candidate.

“I’ll also help ensure our party continues to be remade in the image of the activism I’ve seen all across this nation,” he wrote in the op-ed.

The mayor even gave a backhanded compliment to the president.

“Donald Trump lies to working people, but he at least pretends to talk to them,” de Blasio wrote.

“That may be enough for him to win, if we do not constantly make it clear that the Democrats are the party of everyday Americans in rural counties and urban centers, the coasts and the heartland,” he added.

De Blasio claimed he could juggle his day job with his 2020 schedule, but he only spent seven hours at City Hall during the first month of his campaign, according to a Post analysis.

“Most people thought that at worst, a presidential campaign would keep him stuck in neutral at home,” said Eric Soufer, who worked on presidential campaigns for John Edwards and Barack Obama and advised former state Attorney General Eric Schneiderman.

“But it actually sent him backward, by raising new concerns about his fundraising practices, energizing his critics on the left and right, and making it crystal clear that for whatever reason, New Yorkers do not think he’s in the same league as just about anyone else on that debate stage.

“Hopefully it’s a come-to-Jesus for him and he finds a way to resurrect what was once a promising, if controversial, mayoralty,” Soufer said.

De Blasio’s campaign events in primary states regularly attracted no more than 15 people. He got more attention for missteps like getting stuck in Waterloo, Iowa, during July’s Big Apple blackout than policy proposals.

The term-limited mayor announced his decision to pull out of the crowded Democratic field after falling far short of the qualifying requirements to make the last two primary debates. Contenders had to poll at 2 percent and attract 130,000 donors. On average, less than 1 percent of Democratic voters selected de Blasio as their candidate in national surveys and fewer than 65,000 donors had contributed to his campaign as of late August.

A recent Siena College Research Institute poll found Hizzoner had lower favorability ratings from New Yorkers than President Donald Trump — 25 percent compared to 32 percent. In the city, just one person — a white male — out of 389 Democrats responding to the poll said he’d vote for de Blasio, leading a Washington Post columnist to speculate whether that would-be voter was the mayor himself.

Among his own city constituents, de Blasio edged out Trump by just 10 percentage points in the Siena survey.

Meanwhile, ethics questions dogged de Blasio as he received hundreds of thousands in campaign contributions from people or businesses with interests before the city.

As of the last public accounting, 70 percent of the mayor’s 6,700 donors were tied to the city’s powerful Hotel Trades Council that has benefited from de Blasio’s battle against Airbnb.

De Blasio also ordered his Planning Department to study mandatory permitting for all new hotels across the city that would give the HTC tremendous leverage to require unionized labor in the hotels.

Good-government advocate Susan Lerner said the order, “at a minimum, creates the appearance of impropriety and illegality.”

The mayor has called pay-to-play allegations “ridiculous,” but they remind New Yorkers about his long history of fundraising scandals.

As the mayor reshifts his focus to City Hall full-time, he faces a host of at-home woes from crumbling public housing to homelessness.