“I want to be quiet a little bit and not hear myself talk so darn much,” he said at his final news conference on Jan. 18. “But there’s a difference between that normal functioning of politics and certain issues or certain moments where I think our core values may be at stake. I put in that category, if I saw systematic discrimination being ratified in some fashion.”

Mr. Obama was still on vacation with his wife in Palm Springs, Calif., on Monday and was not available for an interview, Mr. Lewis said. But after a weekend of watching chaos at airports as green card holders and many others were detained, aides said the former president felt it was vital to express his views.

Mr. Obama was also determined, they added, to push back against the argument — made by Mr. Trump’s advisers as they defended the order — that it had been Mr. Obama’s idea to bar entrants from certain predominantly Muslim countries.

Mr. Obama’s comments came with a reminder that he had in the past spoken out against the kind of tactics Mr. Trump employed on Friday, when he ordered a temporary halt to admitting people from Iran, Iraq, Libya, Syria, Somalia, Sudan or Yemen and a freeze on the United States refugee program, which he said should give priority to Christians in the future.

Along with Mr. Obama’s statement, Mr. Lewis appended a section of remarks the former president delivered in November 2015 at a summit in Antalya, Turkey, when he spoke out against a Muslim ban that Mr. Trump, then a candidate for president, had proposed.

“When I hear folks say that, well, maybe we should just admit the Christians but not the Muslims; when I hear political leaders suggesting that there would be a religious test for which a person who’s fleeing from a war-torn country is admitted, when some of those folks themselves come from families who benefited from protection when they were fleeing political persecution — that’s shameful,” Mr. Obama said then. “That’s not American. That’s not who we are. We don’t have religious tests to our compassion.”