WASHINGTON — President Trump on Friday closed the nation’s borders to refugees from around the world, ordering that families fleeing the slaughter in Syria be indefinitely blocked from entering the United States, and temporarily suspending immigration from several predominantly Muslim countries.

In an executive order that he said was part of an extreme vetting plan to keep out “radical Islamic terrorists,” Mr. Trump also established a religious test for refugees from Muslim nations: He ordered that Christians and others from minority religions be granted priority over Muslims.

“We don’t want them here,” Mr. Trump said of Islamist terrorists during a signing ceremony at the Pentagon. “We want to ensure that we are not admitting into our country the very threats our soldiers are fighting overseas. We only want to admit those into our country who will support our country, and love deeply our people.”

Earlier in the day, Mr. Trump explained to an interviewer for the Christian Broadcasting Network that Christians in Syria were “horribly treated” and alleged that under previous administrations, “if you were a Muslim you could come in, but if you were a Christian, it was almost impossible.”

“I thought it was very, very unfair. So we are going to help them,” the president said.

In fact, the United States accepts tens of thousands of Christian refugees. According to the Pew Research Center, almost as many Christian refugees (37,521) were admitted as Muslim refugees (38,901) in the 2016 fiscal year.

The executive order suspends the entry of refugees into the United States for 120 days and directs officials to determine additional screening ”to ensure that those approved for refugee admission do not pose a threat to the security and welfare of the United States.”

The order also stops the admission of refugees from Syria indefinitely, and bars entry into the United States for 90 days from seven predominantly Muslim countries linked to concerns about terrorism. Those countries are Iraq, Syria, Iran, Sudan, Libya, Somalia and Yemen.

Additionally, Mr. Trump signed a memorandum on Friday directing what he called “a great rebuilding of the armed services,” saying it would call for budget negotiations to acquire new planes, new ships and new resources for the nation’s military.

“Our military strength will be questioned by no one, but neither will our dedication to peace,” Mr. Trump said.

Announcing his “extreme vetting” plan, the president invoked the specter of the Sept. 11, 2001, attacks. Most of the 19 hijackers on the planes that crashed into the World Trade Center, the Pentagon and a field in Shanksville, Pa., were from Saudi Arabia. The rest were from the United Arab Emirates, Egypt and Lebanon. None of those countries are on Mr. Trump’s visa ban list.

Human rights activists roundly condemned Mr. Trump’s actions, describing them as officially sanctioned religious persecution dressed up to look like an effort to make the United States safer.

The International Rescue Committee called it “harmful and hasty.” The American Civil Liberties Union described it as a “euphemism for discriminating against Muslims.” Raymond Offensheiser, the president of Oxfam America, said the order would harm families around the world who are threatened by authoritarian governments.

“The refugees impacted by today’s decision are among the world’s most vulnerable people — women, children, and men — who are simply trying to find a safe place to live after fleeing unfathomable violence and loss,” Mr. Offensheiser said.

The president signed the executive order shortly after issuing a statement noting that Friday was International Holocaust Remembrance Day, an irony that many of his critics highlighted on Twitter. The statement did not mention Jews, although it cited the “depravity and horror inflicted on innocent people by Nazi terror.”

Mr. Trump’s actions came during a swearing-in ceremony for Secretary of Defense Jim Mattis, a former Marine general. Standing in the Hall of Heroes at the Pentagon, Mr. Trump hailed the members of America’s military as “the backbone of this country” and described Mr. Mattis as a “man of action.” The president mistakenly referred to Mr. Mattis as a “soldier,” a term abhorred by Marines.

Mr. Trump has been deferential to Mr. Mattis, who has quickly established himself as a top aide whose advice the president is willing to take. On Friday, Mr. Trump said he would let Mr. Mattis “override” him by banning torture during terror interrogations even though Mr. Trump believes the tactics do work in getting information from suspects.

In a remarkable show of deference to his own subordinate, Mr. Trump said during an earlier news conference Friday morning with Theresa May, the British prime minister, that he would let Mr. Mattis decide about whether to use torture in interrogations. Mr. Mattis has said he does not believe torture is effective.

“I don’t necessarily agree, but I will tell you that he will override because I’m giving him that power,” Mr. Trump said. “I’m going to rely on him. I happen to feel that it does work.”

Mr. Mattis spent his first week as defense secretary trying to reassure not only American allies, but also military rank and file, that the United States will not abandon a national security structure that has stood in place since the end of World War II. He has told officials in the Pentagon building that at an uncertain time, he intends, as defense secretary, to provide an even-keeled, measured approach to national security issues.

Before the signing ceremony, Mr. Trump met with Mr. Mattis and his military chiefs for about an hour. The meeting — which took place in a Pentagon secure room known as “the tank” — included introductions for Mr. Trump to his military chiefs of staff. The meeting was attended by Michael Flynn, the national security adviser; Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff; and the chiefs of the four services and the National Guard.

The men discussed how to accelerate the fight against the Islamic State and North Korea and how to deal with a host of global challenges, said a defense official who was not authorized to talk publicly about the internal talks. The leaders also discussed how to improve military readiness.

The newly sworn-in secretary of defense also gave Mr. Trump a little of what the president has been asking — or tweeting — for. On Thursday, Mr. Mattis ordered a review of the controversial F-35 Joint Strike Fighter program, which has been criticized by Mr. Trump for its cost overruns.

Mr. Mattis also ordered that plans for a new Air Force One — another project that has come under fire from Mr. Trump — should be reviewed, “with the specific objective of identifying means to substantially reduce the program’s costs while delivering needed capabilities.”

The F-35 review, Mr. Mattis said in a memo, will also look at how to reduce costs while still meeting requirements set out for the fighter jet program.

During his confirmation hearings this month, Mr. Mattis defended Twitter messages from Mr. Trump criticizing the F-35 program. Mr. Mattis said at the time that Mr. Trump had “in no way shown a lack of support for the program,” adding, “He just wants more bang for the buck.”

The cost of building the F-35 next-generation fighter jet has been an issue at the Pentagon for several years. At an estimated $400 billion over 15 years for 2,443 planes, the fighter jet is the military’s largest weapons project.