Former President Barack Obama has praised protesters who amassed across the country in opposition to President Donald Trump's immigration orders, breaking his silence on political issues for the first time since leaving office.

"The president fundamentally disagrees with the notion of discriminating against individuals because of their faith or religion," Mr Obama's spokesman Kevin Lewis said.

In his first statement on behalf of the former president, Mr Lewis said Mr Obama was "heartened" by the amount of engagement taking place in US communities.

Mr Lewis, a former White House official, pointed out that Mr Obama used his last official speech as president to talk about Americans' responsibility to be "guardians of our democracy," even in non-election years.

"Citizens exercising their constitutional right to assemble, organise and have their voices heard by their elected officials is exactly what we expect to see when American values are at stake," Mr Lewis said.

Mr Lewis did not specifically invoke President Trump's immigration order. But he rejected comparisons between Mr Trump's recent actions and Mr Obama's foreign policy decisions.

President Trump said he took cues from Mr Obama by temporarily banning travel to the US from citizens of seven countries that Mr Obama's administration identified as places of terrorism concern.

But Mr Obama's designation related strictly to eligibility to enter the US without a visa; he never considered a travel ban.

Mr Obama's office also circulated excerpts from a speech the former president gave in November 2015, in which he called the idea of a ban on Muslims "shameful".

"That's not American. That's not who we are. We don't have religious tests to our compassion," Mr Obama said in the aftermath of attacks in Paris that prompted calls for the US to restrict Syrian refugees from entering the United States.

President Trump and the White House have vigorously disputed the notion that Mr Trump's order is a "Muslim ban".

The order halts all refugee admissions for 120 days, suspends the Syrian refugee programme indefinitely and also suspends entry to the US from seven majority-Muslim countries for 90 days.

But the White House has stressed that dozens of other Muslim-majority countries are not included.

Mr Lewis's comments mark the first time Mr Obama has weighed in on President Trump's actions since he left office on January 20.

In his final weeks as president, Mr Obama said he planned to follow George W Bush's example by giving his successor room to govern without being second-guessed.

Yet Mr Obama pointedly reserved the right to speak out if President Trump violated what Mr Obama called basic American values.

He suggested a ban on Muslims or a move by President Trump to deport immigrants brought to the US illegally as children would cross that threshold.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.