Former New York City mayor Michael R. Bloomberg said Monday that he will not run for president this election cycle.

“I’m flattered that some think I could provide this kind of leadership,” he said in an essay posted on the website Bloomberg View an fast-paced opinion publication. “But when I look at the data, it’s clear to me that if I entered the race, I could not win.”

Bloomberg, 74, one of the world’s wealthiest men, used the essay to put to rest months of speculation over whether he would enter the race — and thereby scramble an already chaotic contest — as well as to criticize Republican presidential candidates Donald Trump and Sen. Ted Cruz (Tex.).

A Bloomberg candidacy could tip the election in their favor, he said, adding, “That is not a risk I can take in good conscience.”

“I have known Mr. Trump casually for many years, and we have always been on friendly terms,” he said in “The Risk I Will Not Take.” “I even agreed to appear on ‘The Apprentice’ — twice. But he has run the most divisive and demagogic presidential campaign I can remember, preying on people’s prejudices and fears. Abraham Lincoln, the father of the Republican Party, appealed to our ‘better angels.’ Trump appeals to our worst impulses.”

Bloomberg described Trump’s call for a temporary ban on Muslims entering the United States as “a direct assault” on the core American values of religious tolerance and the separation of church and state. He also criticized Trump for promising to deport millions of undocumented Mexican immigrants, “feigning ignorance of white supremacists” and threatening trade wars with other countries.

“These moves would divide us at home and compromise our moral leadership around the world,” Bloomberg said. “The end result would be to embolden our enemies, threaten the security of our allies, and put our own men and women in uniform at greater risk.”

He also described Cruz’s position on immigration as “no less extreme” and “no less divisive.”

Bloomberg did not mention Hillary Clinton and Bernie Sanders, the candidates for the Democratic nod. He said he is not ready to issue an endorsement, but he vowed to remain vocal about what he called “partisan extremism.”

Several publications reported in January that he was exploring a run as the prospect of a Trump nomination transitioned from possibility to probability.

Bloomberg’s candidacy would have relied on what Gallup, the polling organization, has identified as a growing number of American voters dissatisfied with both major political parties.

And voters who see Trump and Cruz as too extreme might have been drawn to Bloomberg, a onetime Democrat who became a Republican and ultimately declared himself unaffiliated in 2007.

“There is a broad constituency, and there will be a broader one still, given the polarization of this election,” Douglas Schoen, Bloomberg’s pollster, wrotesaid in a February Wall Street Journal commentary titled “Why Mike Bloomberg Can Win.”

But a potential Bloomberg candidacy threatened to tilt the race in favor of Republican candidates.

“He would likely draw many more Democratic voters than Republicans, helping the Republican nominee win swing states or throwing the election to the House,” Stuart Rothenberg, editor of Roll Call, a nonpartisan newsletter covering state and federal campaigns, said last month.

It was that possibility that Bloomberg sought to avoid.

“I love our country too much to play a role in electing a candidate who would weaken our unity and darken our future — and so I will not enter the race for president of the United States,” Bloomberg said.

The timing of his announcement was driven in part by ballot access requirements, he said.

Related stories: