District judge Naomi Buchwald ruled [PDF] that Trump's blocking of critics from his Twitter account @realDonaldTrump is illegal since it is "properly characterized as a designated public forum" given his public position.
"Blocking of the plaintiffs based on their political speech constitutes viewpoint discrimination that violates the First Amendment", wrote Buchwald, adding that Trump's Twitter account is "a kind of digital town hall in which the president and his aides use the tweet function to communicate news and information to the public".
"The blocking of the individual plaintiffs from the @realDonaldTrump account due to their expressed political views violates the First Amendment", declared the judge, a Clinton appointee who serves on a court in NY. "The answer to both questions is no", she concluded.
The case was brought by the Knight First Amendment Institute at Columbia University and seven Twitter users whose accounts had been blocked.
The president uses his account, which has 37,600 tweets and 52.2 million followers, to "take measures that can only be taken by the president as president", the ruling reads.
President Trump and the other defendants conceded they did so because they disliked the viewpoints the plaintiffs expressed in their tweets.
However, the US Department of Justice opposed with the court decision.
The judge's ruling is a landmark one as there are few laws governing interaction in the social media space.
Ariana Grande sends love to Manchester one year after attack
As I said at the time of the attack, this was a despicable and evil crime which should be condemned by everyone. Bells on the city hall and churches will ring out at 10:31 p.m., exactly a year since the bomb exploded.
Pompeo: Iran 'marched across Mideast' under nuke deal
He said: "We can not let the United States flout global law, their behaviour towards Iran is unacceptable". The deal was created to prevent Iran from developing a nuclear weapon. "Iran was committed to the deal".
US Air Force apologizes for 'Yanny or Laurel' Afghan war tweet
The initial tweet was deleted and replaced with an apology that said the initial post was "made in poor taste". Next time get a perspective from the folks who carried out the missions.
It's unclear if Mr Trump will now unblock his critics, but the judge hinted the president could face legal action if he did not comply with the ruling.
He often eschews the official U.S. presidential Twitter account, @POTUS, as well as his own White House press office, to make official announcements.
"We receive reports about how governmental officials manipulate social media comments to exclude opposing views to create the impression that hotly contested policies are not contested at all", EFF said on Twitter after the case was filed. She disagreed with the government's assertion that the blocked Twitter users' right to free speech does not apply in this case because Trump was acting as a private individual through his @realDonaldTrump account.
Buchwald said Trump could opt to mute his critics instead. "If all goes well, Hollywood will immortalize him as an evildoer who got his comeuppance". In July, a federal court in Virginia said the chair of a county board of supervisors had violated the First Amendment rights of a constituent by blocking him from the county's Facebook page.
The government did not dispute that Mr. Trump blocked people because of those kinds of antagonistic tweets.
If Twitter is a public forum where users have First Amendment rights, that could make Twitter bans unconstitutional as well.
It is unclear if Trump would unblock those he had blocked and the judge did not explicitly rule on that. In last year's ruling about Facebook blocking, the judge held that public officials could do a certain amount of content moderation, provided that it was done in a content-neutral manner.