If Donald Trump were a religious man, he might have said “There but for the grace of God go I” when he heard that former Brazilian president Jair Bolsonaro has been sentenced to 27 years in prison. Bolsonaro’s crime was to have plotted a coup to take back the presidency he lost in the 2022 election.

Trump is acutely aware of the similarities between Bolsonaro’s case and his own bumbling, half-hearted attempt to incite a coup on January 6, 2021. Both men were voted out after a single term in office, both immediately declared that the election had been ‘stolen’ by the opposition, and both then chickened out of a coup at the last moment.

Trump feels the parallels so keenly that he did not just condemn the Bolsonaro trial, claiming that it was a “witch-hunt”. Although the United States has a positive trade balance with Brazil, Trump has imposed 50% tariffs on imports from Brazil as an explicit punishment for putting his friend and ally on trial.

Trump must be feeling close to all-powerful right now. Only eight months into his second term after a triumphant comeback election, he is nearing the point where he can sweep the whole 238-year-old constitutional apparatus of the United States aside and rule by decree.

Indeed, to a large extent he already rules by decree, with both the Supreme Court and the two Houses of Congress subservient to his will. But he has not done anything irrevocable yet, so there is still some point in considering why Brazil’s democracy has survived while America’s is in great peril.

The Brazilian coup plans were serious and extensive. Four top military officers were involved and assassins from the special forces were to kill a Supreme Court judge and the president-elect (Luiz Inácio ‘Lula’ da Silva). That would have provided a pretext for a military take-over.

The plans were printed out in the Presidential Palace, and a ‘popular’ uprising of Bolsonaro supporters would have coincided with the assassinations to justify the take-over of the federal government.

But it didn’t happen because the army and air force heads refused to go along with the coup. The assassins were called off literally at the last moment. A mob of Bolsonaristas eventually showed up in Brasilia and stormed the Congress and the Supreme Court, but it was all over by then so they just vandalised the buildings and went home again.

The siege of the US Congress the previous January was a less organised affair. Trump’s most extreme supporters had been planning a protest in Washington on the day when Vice-President Pence was supposed to ratify the election results, but Trump’s incendiary speech on the morning of January 6 was short on detailed instructions and then he went home.

A mob of extreme Trump backers broke into the Capitol and they might have murdered Pence if they had caught him, but this shambles was never going to end as a successful coup. Compared to the Brazilian events it was much less serious – yet look which country is in deep trouble now. What went wrong in the United States?

Basically, Brazil brought the guilty men to book right away (although the actual court proceedings took a long time). The United States waited too long, and Trump went got away with it.

Initially, both houses of the US Congress were ready to impeach Trump (who was still in office for another two weeks). “The mob was fed lies. They were provoked by the president,” said Mitch McConnell, the Republican majority leader of the Senate.

If Congress had acted promptly, the impeachment would have been successful, and Trump could never have run again. But they waited, and the old partisan loyalties quickly reasserted themselves, and it never did happen.

That is not to say that another hard-right populist could not have won the US election in 2024, but it would have been a lot less likely. The old, law-abiding Republican Party might have taken back control, and the extremists on both sides might have been rejected. But maybe not, because the polarisation is more deeply entrenched in the United States.

An overwhelming majority of Republican voters still believe that Trump really won the 2020 election. By contrast, only 36% of Brazilians doubt that Bolsonaro was part of the coup plot, even though the voters are almost equally split between him and Lula.

There is an election due in Brazil next year, and if Bolsonaro’s party wins the presidency he would swiftly be amnestied. Nothing is certain, but for the moment Trump’s assault on Brazil’s sovereignty is pushing public opinion in Lula’s favour. Meanwhile, in the US, the scene darkens.

Gwynne Dyer’s new book is ‘Intervention Earth: Life-Saving Ideas from the World’s Climate Engineers’. The previous book, ‘The Shortest History of War’, is also still available.