By Newley Purnell and Andrew Restuccia

Twitter Inc. shielded from public view tweets from President Trump and the White House for breaking what the company said are its rules about glorifying violence, a step that is likely to escalate tension between the president and the social-media giant.

The decision came one day after Mr. Trump signed an executive order taking aim at what he alleged was censorship by social-media companies, calling Twitter "an editor with a viewpoint."

Mr. Trump, in tweets posted shortly after midnight on Friday, criticized protesters clashing with police in Minneapolis over the death of George Floyd, a black man who died Monday after a white officer pinned him to the ground with a knee to his neck. The protests have turned violent, with a police station being set on fire overnight.

The president called the demonstrators thugs and warned: "When the looting starts, the shooting starts."

That phrase has a fraught history dating back to 1967, when Miami Police Chief Walter Headley used it at a news conference to explain how the threat of police violence had prevented riots and looting in the city. Mr. Headley's comments and his "get-tough" approach to crime sparked outrage in Miami's black community, and riots broke out in the city in the summer of 1968.

Mr. Trump's post can now only be seen after users click a box with a notice saying it violated Twitter's rules against encouraging violence, but it otherwise remains visible.

The official White House Twitter account repeated Mr. Trump's comments in a Friday tweet, and Twitter appended the same notice to that tweet. The same comments appeared on Mr. Trump's Facebook account without a cautionary notice.

"We've taken action in the interest of preventing others from being inspired to commit violent acts, but have kept the Tweet on Twitter because it is important that the public still be able to see the Tweet given its relevance to ongoing matters of public importance," Twitter said on its official communications account.

The company said users' ability to interact with the tweet will be limited, and that users can retweet it with comment, but not like, reply to, or retweet it.

Mr. Trump said Friday he wasn't encouraging police to shoot protesters. Referring to his looting and shooting comments, the president wrote on Twitter: "I don't want this to happen, and that's what the expression put out last night means."

He added in a second tweet, "It was spoken as a fact, not as a statement. It's very simple, nobody should have any problem with this other than the haters, and those looking to cause trouble on social media."

Mr. Trump added later Friday that he didn't know where the "looting" phrase originated but that his intent in using it was to say "when there's looting, people get shot and they die."

In the earlier tweets, which were posted to his account at 12:53 a.m., Mr. Trump criticized Minneapolis Mayor Jacob Frey, a Democrat, alleging a "total lack of leadership" in response to the protests. Mr. Trump also suggested that the federal government could take a more central role in responding to the protests, warning of the potential for intensifying violence.

"...These THUGS are dishonoring the memory of George Floyd, and I won't let that happen. Just spoke to Governor Tim Walz and told him that the Military is with him all the way. Any difficulty and we will assume control but, when the looting starts, the shooting starts. Thank you!" Mr. Trump's tweet said.

Mr. Trump said he would send the National Guard to Minnesota. Gov. Walz activated the National Guard on Thursday.

Mr. Frey responded to Mr. Trump's tweets during a news conference Friday. " Donald Trump knows nothing about the strength of Minneapolis. We are strong as hell," he said.

Former Vice President Joe Biden, the presumptive Democratic presidential nominee, criticized Mr. Trump's tweets in a televised address.

"This is no time for incendiary tweets. It's no time to encourage violence," he said. "This is a national crisis, and we need real leadership right now."

The move by Twitter escalates a dispute with the president that could change the legal environment in which the industry operates. Mr. Trump on Thursday signed an executive order seeking to limit the broad protection that federal law currently provides to social-media and other internet platforms, a move expected to draw immediate court challenges.

The president signed the executive order after Twitter on Tuesday moved for the first time to apply a fact-checking notice to tweets by the president on the subject of voter fraud.

The executive order seeks to make it easier for federal regulators to hold companies like Twitter and Facebook Inc. liable for unfairly curbing speech by suspending users' accounts or deleting their posts, for example.

Speaking just before signing the order Thursday, Mr. Trump described Twitter's fact-check of his tweets as "political activism."

"Imagine if your phone company silenced or edited your conversations. Social-media companies have vastly more power and more reach than any phone company in the United States," he said.

Online-speech and digital-privacy experts said Twitter must now apply its policy consistently across the platform, including to all Mr. Trump's tweets in the months of campaigning ahead.

"It's perhaps the bravest, riskiest thing any tech giant has ever done," said Carl Miller, who directs social-media research at Demos, a London-based think tank. "They can't back down now."

Cindy Cohn, executive director of the Electronic Frontier Foundation, a San Francisco-based digital-rights group, said that while Twitter was within its rights to flag the president, the platform is too large to moderate content effectively.

"The whole idea of doing content moderation at scale just has so many problems," she said. "It just doesn't work very well."

Twitter's rules against glorification of violence prohibit comments that could inspire others to commit similar acts, or that praise or condone violence where ethnic or racial groups are targeted.

The company also has public-interest exceptions under which it may preserve posts that violate its policies when they come from government officials and could contribute to discussion about matters of concern.

"As a result, in rare instances, we may choose to leave up a Tweet from an elected or government official that would otherwise be taken down," Twitter's policy on public-interest exceptions says.

Though this week marked the first time that Twitter put notifications on Mr. Trump's tweets, the company in March applied the label "manipulated media" to the bottom of a video circulated by Dan Scavino, a senior adviser to the president.

--Parmy Olson contributed to this article.

Write to Newley Purnell at newley.purnell@wsj.com and Andrew Restuccia at Andrew.Restuccia@wsj.com