Bill O’Reilly has been forced out of his position as a prime-time host on Fox News, the company said on Wednesday, after the disclosure of settlements involving sexual harassment allegations against him. His abrupt and embarrassing ouster ends his two-decade reign as one of the most popular and influential commentators in television.

“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 parent company of Fox News, said in a statement.

Mr. O’Reilly is departing two and a half weeks after an investigation by The New York Times revealed how Fox News and 21st Century Fox had repeatedly stood by him even as sexual harassment allegations against him mounted. The Times found that the company and Mr. O’Reilly had reached settlements with five women who had complained about sexual harassment or other inappropriate behavior by him. The agreements totaled about $13 million.

Since then, more than 50 advertisers had abandoned his show, and women’s rights groups had called for his ouster. Inside the company, women expressed outrage and questioned whether top executives were serious about maintaining a culture based on “trust and respect,” as they had promised last summer when another sexual harassment scandal forced the ouster of Roger E. Ailes as chairman of Fox News.