Sen. Jeff Sessions said Tuesday that if confirmed as attorney general he would oppose moves to block Muslims from entering the United States, a controversial proposal by President-elect Donald Trump to combat terrorism.

The Alabama Republican told the Senate panel conducting his confirmation hearing that Mr. Trump and himself were “great believers in religious freedom” and he would not support a religious test for visitors or immigrants.

“I do not support the idea that Muslims as a religious group should be denied entry to the united states,” Mr. Sessions said.

However, he said that people who ascribe to violent religious extremism should be prevented from entering the country.

He noted that Mr. Trump had modified the proposal during the presidential race to focus on countries that are hotbeds of terrorist activity.

“He has indicated that would he would suggest is strong vetting of people coming form those countries,” Mr. Sessions said.

The proposal for a temporary Muslim ban, which Mr. Trump said would be used until authorities figured out how to screen people for terrorism, prompted accusations that Mr. Trump is a bigot.

During the campaign, Mr. Sessions did support Mr. Trump’s proposal, which was made in the wake of the December 2015 terror attack in San Bernardino, California, that killed 14 people at an office Christmas party.