A Brazilian Supreme Court justice has threatened to shut down the local operations of X, formerly Twitter, unless its billionaire owner Elon Musk names an in-country legal representative within 24 hours.

The order from Justice Alexandre de Moraes on Wednesday is the latest development in an ongoing feud with Musk's platform. The company has clashed with de Moraes earlier this year over free speech, accounts associated with the far-right and misinformation, and it claims to be a victim of censorship.

Earlier this month, X said it was removing all remaining Brazil staff in the country “effective immediately,” saying de Moraes had threatened its legal representative with arrest.

The Supreme Court on Wednesday notified X of de Moraes' order in a reply to a post from the company's global government affairs account on the social platform.

“In case of non-compliance with the determination, the decision could bring about suspension of the social media network's activities in Brazil,” the court said in a statement.

In the United States, free speech is a constitutional right that's much more permissive than in many countries, including Brazil, where de Moraes in April ordered an investigation into Musk over the dissemination of defamatory fake news and another probe over possible obstruction, incitement and criminal organisation.

Brazil's political right has long characterised de Moraes as overstepping his bounds to clamp down on free speech and engage in political persecution. His defenders have said his actions are lawful, supported by at least the majority of the court's bench, and have served to protect democracy at a time in which it is imperiled.