Alexandre de Moraes ordered the "immediate and complete suspension" of the social media platform until it complies with all court orders and pays existing fines.
The row began in April, with the judge ordering the suspension of dozens of X accounts for allegedly spreading disinformation.
Reacting to the decision, X owner Elon Musk said: "Free speech is the bedrock of democracy and an unelected pseudo-judge in Brazil is destroying it for political purposes."
It is the latest in a series of rows involving Mr Musk - he has clashed with the with EU over the regulation of X and earlier this month became embroiled in a war of words with UK Prime Minister Sir Keir Starmer.
The head of Brazil's telecommunications agency, which has been tasked with suspending the platform, said he is "proceeding with the compliance" to do so, according to Reuters news agency.
The platform is expected to be unavailable in the country within the next 24 hours.
Justice Moraes has given companies such as Apple and Google a five-day deadline to remove X from its application stores and block its use on iOS and Android systems.
He added that people or businesses using means such as VPNs (virtual private network) to access the platform could be fined R$50,000 (£6.7k).
According to the judge's order, a ban will be in effect until X names a new legal representative in the country and pays fines for violating Brazilian law.
In a previous post from one of its official accounts, X had said it would not comply with the demands.
"Soon, we expect Judge Alexandre de Moraes will order X to be shut down in Brazil – simply because we would not comply with his illegal orders to censor his political opponents," the post said.
"The fundamental issue at stake here is that Judge de Moraes demands we break Brazil’s own laws. We simply won’t do that."
Justice Moraes had ordered that X accounts accused of spreading disinformation - many supporters of the former right-wing president Jair Bolsonaro - must be blocked while they are under investigation.
He said the company's legal representatives would be held liable if any accounts were reactivated.
Sofia Ferreira Santos