A judge has barred a planned celebration marking the anniversary of the 1964 Brazilian coup which overthrew the democratic government.
President Jair Bolsonaro had planned to celebrate the anniversary of the start of military rule on Sunday.
The far-right president's decision had provoked widespread condemnation.
He defended the decision earlier this week, stating the aim was to remember the era rather than commemorate military rule itself.
Judge Ivani Silva da Luz said the event celebrating the 55th anniversary of the coup was not "compatible with the process of democratic reconstruction".
He said commemorative dates must be approved by the country's Congress.
During the 21 years of dictatorship in the 1960s and 70s, at least 434 people were killed or disappeared, according to the findings of a 2014 national truth commission.
None of the military officials in power at the time has been prosecuted.
Mr Bolsonaro, who is a former army captain and openly admires former dictators, was elected in October.
He is a divisive figure who has sparked controversy with racist, homophobic and misogynistic comments.
Opposition to the planned celebrations had been growing throughout the week, with calls on social media for street protests in Sao Paulo and Rio de Janeiro.
On Tuesday, Brazil's Federal Public Prosecutor's Office (MPF) issued a statement that said celebrating the dictatorship would be celebrating "an unconstitutional regime responsible for serious crimes of violation of human rights".
"This initiative sounds like an apology for the practice of mass atrocities and therefore deserves social and political repudiation," the statement continued.