A Brazilian judge has overturned a ban on commemorations of the 1964 coup overthrowing the democratic government.
Far-right President Jair Bolsonaro had planned to mark the anniversary of the start of military rule on Sunday.
On Friday a judge said the event would not be compatible with "democratic reconstruction".
But the appeals judge allowed the government's argument that Brazilian democracy was strong enough to support a "pluralism of ideas".
Judge Maria do Carmo Cardoso said commemorating the coup was not rewriting history, nor hiding the truth.
"I see no violation of human rights, particularly as similar demonstrations took place in the barracks in preceding years, with no negative consequences," she said.
Friday's injunction had been granted after protests from politicians, activists and the Federal Public Prosecutor's Office, which said the planned celebration "sounds like an apology for the practice of mass atrocities".
Mr Bolsonaro defended it earlier this week, stating the aim was to remember the era rather than commemorate military rule itself.
The BBC's Americas regional editor Candace Piette says Mr Bolsonaro, a former army captain, believes the coup was in fact a democratic revolution called for by the people and the press.
The president, who was elected in October, is a divisive figure who has sparked controversy with racist, homophobic and misogynistic comments.
Several military units have already held events marking the coup anniversary and protests against Sunday's events are planned in several cities.
No one has been held accountable in Brazil for the deaths and disappearances during the 21 years of military rule.
In 2014 a national truth commission found that 434 assassinations were carried out in the years after the 1964 coup, as well as arbitrary detentions and cases of torture of political opponents.