The Muslim ban proposed by Republican presidential nominee Donald Trump is “not the America we want”, President Barack Obama has said.
Treating Muslim-Americans differently will only make the country less safe by increasing division between the West and the Muslim world, he said.
On Monday Mr Trump extended his ban plan to people from all countries with a terror history against the US.
He said the deadly Orlando nightclub shootings justified such action.
Forty-nine people were killed when Omar Mateen, a US national with Afghan parents, opened fire in a gay club early on Sunday.
Mr Trump said his proposal could be implemented through unilateral executive action, given the president’s power to “suspend entry into the country of any class of persons that the president deems detrimental to the interests or security of the United States”.
But on Tuesday at the US Treasury in Washington, a visibly angry Mr Obama launched his strongest assault yet on the man who is expected to be confirmed as the Republican nominee next month.
President Obama is often criticised for being emotionally aloof, for being too calm, deliberative. But today, after convening his national security council, his anger came to the fore as he delivered this presidential rebuttal, a general at his side, to Donald Trump and his demand for a ban on Muslims entering America.
Tellingly, he avoided uttering Donald Trump’s name, but the billionaire’s demand after the Orlando massacre that he should resign as president for refusing to use the term “radical Islam” has clearly enraged him.
Mr Trump’s tough-worded response questioned the president’s patriotism. While delighting many of his rusted-on supporters, who see Mr Obama as a weak commander-in-chief who has not done anywhere near enough to combat so-called Islamic State, it may lead more moderate Republicans to again question his temperament and judgment.
In modern-day America, traumatic events like the massacre in Orlando tend to expose the country’s divisions as much as bringing it together. And that’s especially so in this angry election season.
The president said the US had been founded on freedom of religion and having a “religious test” would be against the US Constitution.
He also noted that recent terror attacks in the US had been carried out by people born in the US.
Mateen was born in the same New York neighbourhood as Mr Trump.
The president also urged the US to reinstate the ban on assault weapons.
And he dismissed Mr Trump’s suggestion that he resign because he refuses to use the word “radical Islamic terrorism”.
“If we fall into the trap of painting all Muslims with a broad brush and imply that we are at war with an entire religion, then we are doing the terrorists’ work for them,” he said.
Mr Obama will visit the scene of the carnage in Orlando on Thursday.