US President Donald Trump may not "block" Twitter users from viewing his online profile due to their political beliefs, a judge in New York has ruled.
District Judge Naomi Reice Buchwald in Manhattan said that blocking access to his @realDonaldTrump account would be a violation of the right to free speech.
The lawsuit against Mr Trump and other White House officials stems from his decision to bar several online critics.
The White House has yet to comment on the judge's ruling.
The case was brought by The Knight First Amendment Institute at Columbia University on behalf of seven Twitter users who had been blocked by Mr Trump for criticising him or mocking him online.
On Wednesday the judge agreed with their argument that the social media platform qualifies as a "designated public forum" granted to all US citizens.
"This case requires us to consider whether a public official may, consistent with the First Amendment, 'block' a person from his Twitter account in response to the political views that person has expressed, and whether the analysis differs because that public official is the President of the United States," the judge said in her opinion.
"The answer to both questions is no."
The judge rejected argument by Mr Trump's lawyers that the "First Amendment does not apply in this case and that the President's personal First Amendment interests supersede those of plaintiffs".
Mr Trump has over 52 million followers on Twitter, his preferred social media platform which he joined in March 2009.
He often eschews the official US presidential Twitter account, @POTUS, as well as his own White House press office, to make official announcements.
One of the people that Mr Trump blocked, Holly O'Reilly, who uses the account @AynRandPaulRyan, was blocked last May after posting a GIF of Mr Trump meeting with Pope Francis.
The photo, which some said showed the Pope glaring at Mr Trump, was captioned: "This is pretty much how the whole world sees you."
Shortly after being blocked, she told Time Magazine that "it's like FDR took my radio away", referring to Franklin Delano Roosevelt - the World War Two-era president who spoke directly to Americans with his so-called fireside chats.
Earlier in the trial, Judge Buchwald suggested the president, who was not in court, could simply mute the accounts he does not want to see.
People on Twitter are unable to see or respond to tweets from accounts that block them.
But if Mr Trump muted an account, he would not see that user's tweets but the user could still see and respond to his.
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.
She wrote that "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 his social media director] will remedy the blocking we have held to be unconstitutional".
Trump's safe space
Analysis by Dave Lee, BBC North America technology reporter, San Francisco
When it comes to Twitter, the First Amendment grants the American people the right to speak about the President - but it doesn't force him to listen.
While the court has ruled the blocking is unconstitutional, it said the ability to mute a person was not - and so the safe space nurtured by the president and his social media team will remain mostly intact. As I type this, he follows just 46 people, mostly family and Fox News presenters.
For many of those he blocked, it's become a badge of honour - a #blockedbytrump topic sprung up as a way of celebrating being shut out by The Donald.
But Trump's tweets are a major means by which the president communicates with his people. However history looks back at what is happening within his administration today, tweets will form a crucial part of that record.
And while some have argued that anyone blocked by Trump can see his tweets by just logging out, that doesn't necessarily give the whole picture. One tweet sent on Wednesday does not appear in the feed for logged-out users, for example, as it is a "reply".
Blocking also prevents people from replying to or quoting what was said.
The bigger impact here, however, is that this ruling applies to all public officials in the US.
And so it won't just be Mr Trump thumbing through and unblocking those who he deems unsavoury.