Pharrell Williams. Picture: Reuters

Pharrell Williams has sent a cease-and-desist letter to President Donald Trump.

The 45-year-old singer's lawyer has sent a warning to the US leader after his track 'Happy' was played at the commander-in-chief's political rally in Indiana on Saturday, just hours after a mass shooting at a synagogue in Pittsburgh.

The letter, which was written by attorney Howard King and obtained by The Hollywood Reporter, stated: "On the day of the mass murder of 11 human beings at the hands of a deranged 'nationalist,' you played his song 'Happy' to a crowd at a political event in Indiana.

"There was nothing 'happy' about the tragedy inflicted upon our country on Saturday and no permission was granted for your use of this song for this purpose.

"Pharrell Williams is the owner of the copyright in 'Happy,' with the exclusive right to exploit same. Pharrell has not, and will not, grant you permission to publicly perform or otherwise broadcast or disseminate any of his music."

It is believed 'Happy' was played in support of local congressman Mike Bost.

Pharrell is the latest musician to threaten legal action against the former 'Apprentice' star for using their music at his rallies.

Earlier this month, Omarr Baker, tweeted: "The Prince Estate has never given permission to President Trump or the White House to use Prince's songs and have requested that they cease all use immediately."

And in August, Steven Tyler issued a cease-and-desist letter after Trump's rallies used Aerosmith's 'Livin' on the Edge', three years after he had been issued a warning for using 'Dream On' at campaign rallies while looking to be elected.

A legal notice stated: "By using 'Livin' On The Edge' without our client's permission, Mr. Trump is falsely implying that our client, once again, endorses his campaign and/or his presidency, as evidenced by actual confusion seen from the reactions of our client's fans all over social media."