WASHINGTON—President Donald Trump signed an executive order Friday that indefinitely bans Syrian refugees from entering the U.S. and puts a four-month suspension on the broader refugee program, which has allowed people to flee their homelands and settle in the U.S. for decades.

The executive order, which Mr. Trump signed at the Pentagon, suspends entry into the U.S. of anyone from a number of Muslim-majority countries, including Iraq and Syria.

But it could give priority to Christians living in predominantly Muslim countries who have been persecuted or fear persecution for their beliefs.

At the Pentagon, where Mr. Trump signed the order, the president said the measure would keep “radical Islamic terrorists” out of the U.S.

“We don’t want ‘em here,” he said in the Hall of Heroes. “We want to make sure we are not admitting into our country the very threats our soldiers are fighting overseas.”