US President Donald Trump violated the constitution by blocking Twitter users who disagree with him, a federal judge has ruled.

Judge Naomi Reice Buchwald said the blocking of President Trump’s critics - which prevent them from seeing and interacting with his tweets - violated the free speech rights of those users guaranteed in the constitution's First Amendment.

The judgment will be closely watched for its implications for online free speech.

In a 75-page opinion, the New York federal judge said the users "were indisputably blocked as a result of viewpoint discrimination" and that this was "impermissible under the First Amendment."

The ruling comes in response to a lawsuit filed by a group of Twitter users and the Knight First Amendment Institute at Columbia University.

The lawsuit contended that because Mr Trump uses Twitter for a variety of policy announcements, his Twitter account is "a designated public forum" that cannot exclude people due to their political views.

The judge acknowledged that even though the president has certain free speech rights, he can not violate the rights of other Twitter users.

"While we must recognise, and are sensitive to, the president's personal First Amendment rights, he can not exercise those rights in a way that infringes the corresponding First Amendment rights of those who have criticized him," she said in her opinion.

Judge Buchwald stopped short of accepting the request for an injunction against Mr Trump and his social media aide, Dan Scavino, who was also named in the complaint, saying she expected the White House to abide by her "declaratory" ruling.

"Because no government official is above the law and because all government officials are presumed to follow the law once the judiciary has said what the law is, we must assume that the president and Mr Scavino will remedy the blocking we have held to be unconstitutional," she wrote.