The 5-4 ruling ended an impassioned fight in the courts over whether or not the policy was an unlawful ban on Muslims entering America.

The US president celebrated the ruling on his usual platform of choice - Twitter.

Chief justice John Roberts wrote:

Plaintiffs argue that this president's words strike at fundamental standards of respect and tolerance, in violation of our constitutional tradition. But the issue before us is not whether to denounce the statements. It is instead the significance of those statements in reviewing a presidential directive, neutral on its face, addressing a matter within the core of executive responsibility. In doing so, we must consider not only the statements of a particular president, but also the authority of the presidency itself.

And yet the US president’s actions and words about Muslims have, at times, veered towards the offensive.

Here’s a reminder of comments he’s made about Muslims and Islam in the past:

1. When he said it might be ‘bad’ for Obama to be a Muslim.

On 30 March, 2011, Trump questioned the legitimacy of then US president Barack Obama’s religious beliefs and birth certificate.

He doesn’t have a birth certificate, or, if he does, there’s something on that certificate that is very bad for him. Now, somebody told me – and I have no idea if this is bad for him or not, but perhaps it would be – that where it says ‘religion’, it might have ‘Muslim’. And if you’re a Muslim, you don’t change your religion, by the way.

Barack Obama is a Christian, and he was born in Hawaii.

2. At a New Hampshire rally on 30 September, 2015, he pledged to kick all Syrian refugees out of the country on the grounds that ‘they could be ISIS’.

He said:

They could be ISIS, I don’t know. This could be one of the great tactical ploys of all time. A 200,000-army, maybe. This could make the Trojan horse look like peanuts.

3. He once said he would ‘consider’ closing down mosques in the US.

Speaking on Fox Business on 21 October, 2015, interviewer Stuart Varney asked Trump if he was to be elected president, would he revoke the passports of some people and close mosques.

I don’t know. I mean, I haven’t heard about the closing of the mosque. It depends, if the mosque is, you know, loaded for bear, I don’t know. You’re going to have to certainly look at it.

4. He once said he would create a database of all Muslims in the US.

In comments to Yahoo and NBC News in 2015, Trump was open to the idea of creating a database of all those who practice Islam. When pressed about it by an MSNBC reporter, he said "it would just be good management".

When asked if Muslims would legally have to be part of the database, he responded:

They have to be — they have to be. Let me just tell you: The key is people can come to the country, but they have to come legally.

5. He once said Muslims don't like America.

On MSNBC, a reporter asked Trump if he thinks Islam is an inherently peaceful religion or if it is an inherently violent religion. Trump said:

Well, all I can say… there’s something going on. You know, there's something definitely going on. I don't know that that question can be answered. We are not loved by many Muslims.

6. He once implied America was at war with Muslims.

In March 2016, during a town hall appearance in Wisconsin, CNN journalist Anderson Cooper asked Trump if he trusted Muslims in America. Here’s what Trump said in response:

Many of them I do. Many of them I do, and some, I guess, we don’t. Some, I guess , we don’t. We have a problem, and we can try and be very politically correct and pretend we don’ have a problem, but, Anderson, we have a major, major problem. This is, in a sense, this is a war.

7. He once said Muslims who immigrate to the US can’t assimilate.

In June 2016, during an appearance on Fox News, he said:

Assimilation has been very hard. It’s almost – I won’t say non-existent – but it gets to be pretty close. And I’m talking about second and third generation. They come – they don’t – and for some reason, there’s no real assimilation.

According to the Pew Research Centre, an overwhelming 92 per cent of US Muslims are proud to be American, 97 per cent are proud to be Muslim, and 89 per cent are proud to be both.

8. Trump once shared anti-Muslim videos on Twitter.

In 2018, the US president retweeted three videos from the account of the deputy leader of Britain First, Jayda Fransen.

Britain First is an anti-immigration group in the United Kingdom which has been accused in the past of sharing misleading posts on its social media accounts.