Rupert Murdoch stood behind his top American asset, the anchor Bill O’Reilly of Fox News, for years, shrugging off a sexual harassment scandal in the mid-2000s and multiple complaints about Mr. O’Reilly’s behavior that surfaced behind closed doors.

Mr. Murdoch prizes loyalty and profits, both of which Mr. O’Reilly brought him in droves. And Mr. Murdoch disdains the politically correct mores of the media world, relishing any chance to defy liberal detractors who might challenge his success.

But Mr. Murdoch, 86, has also proved, time and again, that he is a pragmatist at his core — at least, when his hand is forced. Roger E. Ailes, the Fox News creator who generated billions of dollars for Mr. Murdoch, is gone. News of the World, the famed tabloid newspaper at the heart of a hacking scandal, is closed.

Now Mr. O’Reilly, the top cable news host in the United States, is out. Mr. Murdoch signed off on the decision, even if, according to people briefed on the deliberations who spoke on the condition of anonymity to discuss internal matters, it took him longer than others in his circle to get there.

Mr. Murdoch did not build a worldwide corporate empire without making a few hard choices along the way. Fox News may be a major profit center, but Mr. Murdoch has lucrative interests across multiple continents, including the Australian, Asian and European markets.

And his memory is long. When the hacking fracas threatened to subsume his business, Mr. Murdoch watched his bid to acquire Sky, the British satellite and news giant, scuttled by British regulators. Now, he again has Sky in his sights, and Mr. O’Reilly’s troubles surfaced at the moment when Mr. Murdoch must pass a so-called fit and proper test, or a judgment on whether the people who will run the merged company are fit to do so.

Controlling Sky would be highly lucrative, but it was not the only factor that weighed against Mr. Murdoch’s natural fealty to his stars. Advertiser boycotts and protests at the Manhattan headquarters of News Corp, one of Mr. Murdoch’s companies, were ratcheting up pressure. Before Wednesday’s announcement, members of senior management at Fox News’s parent company, 21st Century Fox, were briefed on the results of an internal investigation into Mr. O’Reilly’s behavior.

Mr. Murdoch, who often resists outside pressure, was also being counseled by his sons, James and Lachlan Murdoch, who are the top executives at 21st Century Fox and are intent on steering the family ship far into a new century, with new standards of workplace behavior.

And while Mr. O’Reilly may have been Fox News’s top draw, the channel’s audience is aging. Mr. Murdoch had recently been presented with firsthand evidence that, for viewers, the Fox News message might be more important than the person who delivers it.

Mr. Murdoch, who took over stewardship of Fox News after Mr. Ailes’s departure, decided in January to replace his departing star Megyn Kelly with Tucker Carlson, a seemingly past-his-prime conservative pundit who at the time was best known for wearing colorful bow ties on air.

The television news industry did a double-take. Tucker Carlson? At 9 p.m.?

Mr. Murdoch, it turned out, had the right instincts. Ms. Kelly scored high ratings, but Mr. Carlson routinely outdraws her in the same time slot. His total audience, on some nights, had begun to rival that of Mr. O’Reilly.

Not surprisingly, it was again Mr. Murdoch, this week, who decided that Mr. O’Reilly could be replaced. Mr. Carlson will now take over the 8 p.m. Eastern time slot that “The O’Reilly Factor” is vacating.

Mr. Murdoch despises the perception that he does not stick up for those who are loyal to him. Some of his most cherished lieutenants, like the former News of the World editor Rebekah Brooks, were eventually forced out, only to return later, taking senior positions in Mr. Murdoch’s circle.

Jettisoning Mr. O’Reilly was most likely another painful moment for Mr. Murdoch. But it may have been less so than the episode last summer involving Mr. Ailes, who, besides being a critical colleague, was something of a Murdoch friend, one who helped Mr. Murdoch start Fox News two decades ago.

Mr. O’Reilly and Mr. Murdoch are said to be cordial with each other, according to people who have dealt with both. But corporate executives and on-air talent are rarely very close, especially in an industry in which brands are vital and talent is dispensable.

In a memo to the Fox News staff on Wednesday, Mr. Murdoch praised Mr. O’Reilly as “one of the most accomplished TV personalities in the history of cable news,” and he wrote that he understood “how difficult this has been for many of you.”

The deed, however, was done. And Mr. Murdoch is no fan of dwelling.

“We have full confidence that the network will continue to be a powerhouse in cable news,” he wrote. “Please see attached for our new programming lineup.”