Fox News on Wednesday ended its association with Bill O’Reilly, the combative TV host and commentator who has ruled cable-news ratings for nearly two decades and was the signature figure in the network’s rise as a powerful political player.

The conservative-leaning host’s downfall was swift and steep, set in motion less than three weeks ago by revelations of a string of sexual harassment complaints against him. The questions about his conduct represented yet another black eye to Fox, which had dealt with a sexual harassment scandal involving its co-founder and then-chairman Roger Ailes, just last summer.

[The fall of Roger Ailes: He made Fox News his ‘locker room’ ]

“After a thorough and careful review of the allegations, the company and Bill O’Reilly have agreed that Bill O’Reilly will not be returning to the Fox News Channel,” 21st Century Fox, the channel’s parent company, said in a statement Wednesday. The ousted host stood by his earlier denials of the allegations in a statement issued late Wednesday afternoon.

“Over the past 20 years at Fox News, I have been extremely proud to launch and lead one of the most successful news programs in history, which has consistently informed and entertained millions of Americans and significantly contributed to building Fox into the dominant news network in television,” he said. “It is tremendously disheartening that we part ways due to completely unfounded claims.

Bill O’Reilly is out at Fox News. (Richard Drew/AP)

“But that is the unfortunate reality many of us in the public eye must live with today. I will always look back on my time at Fox with great pride in the unprecedented success we achieved and with my deepest gratitude to all my dedicated viewers. I wish only the best for Fox News Channel.”

The host of “The O’Reilly Factor” got the news while awaiting a flight back to the U.S. from a vacation in Italy. His representatives said he was “resigned” to his demise, having monitored rapidly deteriorating negotiations over his exit over the past several days. O’Reilly wasn’t directly involved in the discussions with the family of Rupert Murdoch, which controls Fox and 21st Century Fox; his attorney, Fred Newman, conducted the talks.

In the end, Newman couldn’t save his client’s job. People close to O’Reilly said Rupert Murdoch and his sons James and Lachlan, who head 21st Century, effectively decided O’Reilly’s fate with little outside discussion. O’Reilly’s contract--signed just last month--contains a clause that enables him to be dismissed under a fixed financial formula, averting protracted negotiations.

The end for O’Reilly was set in motion by a scathing New York Times investigation in early April that revealed that he and Fox had settled five allegations of harrassment brought by Fox employees over a 15-year period. The company and O’Reilly paid out $15 million in exchange for his accusers’ silence.

The Murdochs were well aware of the allegations against O’Reilly when they re-signed their star commentator to a new three-year contract that pays him around $18 million a year. In preparing their story, reporters for the New York Times had sent Fox’s executives a long list of questions, placing senior executives on alert months in advance of its publication.

But the prospect that his accusers — bound by non-disclosure agreements as a result of their settlements — wouldn’t speak in anything but general terms led the company to believe it could weather the Times story.

In fact, it was a sixth accuser — a former guest on O’Reilly’s program named Wendy Walsh — who may have been the key to his unraveling. Unlike the women who received settlements for their complaints, Walsh never sued or settled with O’Reilly, leaving her free to speak in public about her allegations. She did so repeatedly, putting a name, face and voice to the allegations in media accounts.

Shortly after the Times published its story, advertisers began to flee O’Reilly’s program. The boycott kept up as Walsh held press conferences and gave interviews. On Tuesday, another woman came forward, anonymously, to complain that she had been harrassed with racial and sexual comment by O’Reilly in 2008.

The Murdochs ultimately concluded that O’Reilly was vulnerable to further complaints and that the continuing publicity about them would make him untenable in advertisers’ eyes.

In addition to O’Reilly and Ailes, Fox has also lost popular hosts Greta Van Susteren and Megyn Kelly since the turmoil began last summer. The network, however, continued to roll in record ratings, driven in part by viewer interest in Donald Trump, a longtime friend of Ailes, Murdoch and O’Reilly and a frequent interview guest on Fox programs, including “The O’Reilly Factor.”

The loss of O’Reilly, however, is of a different magnitude: “The O’Reilly Factor” has been the network’s flagship show for nearly 20 years, and in many ways has embodied its conservative-oriented spirit.

[How much turmoil can Fox News handle?]

He still seemed to be at the peak of his popularity and prestige only three weeks ago. His 8 p.m. program, which mixes discussion segments with O’Reilly’s pugnacious commentary, drew an average of 4 million viewers each night during the first three months of the year, the most ever for a cable-news program. His popularity, in turn, helped drive Fox News to record ratings and profits. O’Reilly was also the co-author of two books that were at the top of the bestseller lists in April.

O’Reilly had previously survived several controversies during his 21 years at Fox, including a lurid sexual harassment case in 2004 that was fodder for New York’s tabloid newspapers. He also beat back a wave of headlines in 2015, when reporters examined his claims about his days as a young reporter and found them to be dubious. All the while, O’Reilly’s audience not only stuck with him, but continued to grow.

But this time, the intense media coverage surrounding O’Reilly led to a stampede of advertisers away from O’Reilly’s program, leaving it almost without sponsorship over the past two weeks. Various organizations, including the National Organization for Women, called for O’Reilly’s firing, and intermittent protests began outside Fox News’s headquarters in New York. Morale among employees at the network reportedly was suffering, too.

The Murdochs also had more than just O’Reilly’s TV career to consider: The O’Reilly controversy has been casting a shadow over 21st Century’s $14 billion bid to win the British government’s approval to buy Sky TV, the British satellite service. Leaving O’Reilly in place would likely have been a public-relations nightmare for James and Lachlan Murdoch, the sons who head 21st Century Fox, Fox News’s parent.

The Murdoch family abandoned a 2011 offer for Sky amid another scandal, the phone-hacking conspiracy perpetrated by employees of the Murdoch-owned News of the World tabloid in London. A parliamentary panel later declared Rupert and James Murdoch to be “unfit” to run a public company — a description they hoped would not be revived by regulators with the O’Reilly matter hanging over them.

In the wake of the Ailes scandal last summer, the Murdoch brothers vowed to clean up a workplace environment that women at Fox had described as hostile under Ailes. In one of their few public statements on the matter, they said at the time, “We continue our commitment to maintaining a work environment based on trust and respect.”

But those efforts have seemed unavailing, and at times have even seemed hypocritical. Since the Ailes scandal erupted, the company has continued to employ almost all of the senior managers who were in charge when Ailes was allegedly harassing employees, including Bill Shine, currently Fox’s co-president. Shine was accused of enabling Ailes’s retaliatory efforts against an accuser, Fox contributor Julie Roginsky, in a sexual-harrassment lawsuit Roginsky filed earlier this month.

In the end, even an endorsement from President Trump could not save O’Reilly: In an interview with Times reporters on April 5, Trump called O’Reilly “a good person” and said he should not have settled the complaints made against him. “I don’t think Bill did anything wrong,” Trump said.

Fox said that Tucker Carlson, host of a discussion program now airing at 9 p.m., will take over O’Reilly’s 8 p.m. time slot. “Tucker Carlson Tonight,” in turn, will be replaced at 9 p.m. by Fox’s 5 p.m. show, “The Five,” starting on Monday. “The O’Reilly Factor” will continue for the remainder of the week, with guest hosts Dana Perino and Greg Gutfeld. Martha MacCallum and Sean Hannity will remain in their current spots at 7 p.m and 10 p.m., respectively, and the 5 p.m. hour will be occupied by a new show, hosted by Eric Bolling, starting May 1.

O’Reilly hasn’t said what he intends to do next.