Still, the move against Mr. Acosta, a frequent antagonist known for challenging the president during news conferences, was not entirely a surprise.

As a candidate in 2016, Mr. Trump barred journalists from Univision, The Washington Post, BuzzFeed News and Politico from attending his rallies. As president, he has popularized the phrases “enemy of the people” and “fake news” and threatened to pull broadcast licenses and change libel laws to make it easier to sue.

The daily White House press briefing has slowly vanished. In July, a CNN reporter was barred from a Rose Garden event because White House aides said she had asked questions too aggressively.

Mr. Trump and his political team are no doubt aware that Mr. Acosta is a useful foil. “CNN sucks!” is a common chant at the president’s rallies, and there is little political downside for the administration to restrict access to one of the network’s star correspondents. The move is likely to rile Mr. Trump’s opponents, buoy his supporters and have little or no effect on those occupying the nation’s shrinking middle ground.

And, as with most things Trump, nothing was cut-and-dried.

There was the timing: Mr. Acosta’s credential was stripped hours after the president fired his attorney general, Jeff Sessions, and had to explain away a difficult midterm election that handed his Democratic antagonists control of the House. Political strategists observed that a controversy over press rights, instigated by the White House, would make for a useful ploy to distract journalists and perhaps the public.

Then there were the players: a showman president and an ambitious television correspondent in the spotlight.

Mr. Acosta sometimes elicits eye-rolls from others in the White House press corps, who wonder if his aggressive questions are meant less to draw out information from Mr. Trump than to create a camera-ready spectacle. “Most of the people there were serious reporters asking serious questions,” Chris Wallace, the “Fox News Sunday” moderator, said of Wednesday’s news conference. “But Jim Acosta, I thought, embarrassed himself.”