It was money that kept Bill O’Reilly in his bulletproof bully’s pulpit at Fox News despite sordid sex harassment claims dating back 13 years. And in the end, it was money — not morals — that catapulted him out.

For two decades, O’Reilly has been the acid-tongued, anti-political correctness muse and megaphone of the populist right and scolder of the mainstream media — a role that crowned him the undisputed king of cable. The industry’s top-rated host, he made Fox News an essential offering in any basic cable package, and was paid handsomely for it: $18 million last year. Ratings mean advertising dollars, and his 8 p.m. primetime show raked in nearly half a billion bucks in ad revenue between 2014 and 2016 alone, according to Kantar Media research.

But News Corp’s Murdoch family, the corporate owners of Fox News, watched those ad dollars circle the drain this month after an April 1 New York Times report that unearthed numerous sex harassment claims and settlements totaling at least $13 million against O’Reilly. More than 60 advertisers, from Mercedes-Benz and BMW to Orkin and Allstate, dumped his show following pressure exerted by activists, including Media Matters, a progressive media watchdog, Color of Change, a racial justice group, and Sleeping Giants, a campaign to pressure advertisers to boycott what it calls racist and sexist media outlets. Paid ad minutes on “The O’Reilly Factor” plunged by more than two-thirds in the first week after the Times report, and there were protests outside Fox headquarters in New York. O’Reilly insists on his innocence.

Remarkably, O’Reilly’s ratings didn’t suffer; his loyal following spiked during the controversy, up 42 percent in the 25-54 age demographic that advertisers target, according to Nielsen Research. Yet the corporate sponsors were unswayed; it suddenly was less about eyeballs and more about their brands not wanting to be associated with an alleged serial predator.

But here’s what gets me: Fox executives and employees knew long ago about O’Reilly reported behavior, yet some of them tolerated it and covered it up. When a producer recorded him in 2004 making advances, including apparently masturbating and saying he wanted to engage her in obscene acts with a loofah (which he mistakenly called a “falafel”), the case settled, the woman left with a reported payout of $9 million, and King Bill reigned on, unmolested.

The lurid loofah suit was out there, but O’Reilly’s star shined so blindingly bright at Fox that he was invincible. It’s a problem in any workplace culture that enables misbehavior by elites. It may be the boss’s son. It may be top sales staff. In television news and entertainment, it’s all about star power, and for some stars, there’s no accountability or consequences.

Fox knew of hostile behavior claims against O’Reilly at least since 2002, when a settlement was paid to a producer for alleged verbal abuse. Two years later, loofah-gate. Then a drip-drip of other cases that Fox certainly knew of. They also knew of serial sex harassment claims against chairman Roger Ailes, who was only let go last July after former anchor Gretchen Carlson publicized her lawsuit and 20 Fox women backed her, including superstar Megyn Kelly. Kelly reportedly left for NBC partly in frustration over Fox’s handling of the issue.

Remember O’Reilly and Ailes were early boosters of Donald Trump and Fox News helped enable his rise to the presidency with millions of dollars of free media coverage and a megaphone to an audience of likeminded populist nationalists. Trump — who weathered his own sex harassment storm with the “Access Hollywood” tape — has repaid the favor, though with his own anti-Midas touch: both Ailes and O’Reilly were kaput within weeks of getting Trump’s ringing endorsements.

Fox promised last year to clean up its workplace culture after ousting Ailes. We now know at least two claims against O’Reilly were quietly paid after Ailes’s departure.

One of O’Reilly’s regular segments was called “Unresolved Problem.” Well here’s a free idea for Fox: Resolve your old-boy predator problem or you’ll keep losing top female talent and the advertising dollars they drive. We all know that’s The Factor.

This column was originally published in The Boston Globe. It is being republished here with The Globe's permission.