BRASÍLIA — The run-ups to the most recent presidential elections in the Western Hemisphere’s two largest democracies were remarkably similar.
Down in the polls, the right-wing president claimed, without evidence, that the election could be rigged. He suggested that he might not accept a loss. And millions of his followers vowed to take to the streets at his command.
But the outcomes, at least so far, have been drastically different.
In Brazil, when the tallies showed that the incumbent had been voted out after just one term, the government responded jointly, swiftly and decisively. The Senate President, the Attorney General, Supreme Court justices and the heads of the electoral agency went on television together and announced the winner. The House Speaker, perhaps the president’s most important ally, then read a statement reiterating that the voters had spoken. Other right-wing politicians quickly followed suit.
President Jair Bolsonaro, politically isolated, stayed silent for two days. Then, under pressure from his top advisers, he agreed to transfer power.
Thousands of his supporters took to the streets, blocking highways and demanding a military intervention, but the armed forces have shown no interest in disrupting the electoral process. The demonstrations quickly fizzled and the government began its transition.
In the United States, the aftermath was longer, messier and marked by the worst assault on the Capitol in two centuries. President Donald J. Trump and many of his allies denied that he had lost the 2020 election.
Two years later, the nation faces one of the most dire threats to its democracy in generations, with many Republicans openly rejecting what has been repeatedly shown to be a clean election, including many who promote that lie as they seek office in the midterm election on Tuesday.
The differing pictures raise a fundamental question: Is there something the United States, the world’s oldest democracy, can learn from Brazil, a nation that was emerging from military dictatorship when President Biden first ran for the White House in 1988?
Brazil, for its part, has watched closely what has happened in the United States, where democracy did not break after the 2020 election but it did bend.
With similar chaos forecast for their country this year, Brazilians buttressed their system well ahead of time. Government leaders added additional tests of voting machines and checks of the results, they standardized poll hours so the returns would arrive quickly and they planned to present a united front once a winner was declared.
“We learned from the experience of the United States,” said Bruno Dantas, chief of Brazil’s watchdog court, which completed a rapid audit of vote returns on election night intended to pre-empt fraud claims. “We built a network of institutions that anticipated the questions we knew could arise.”
The speed of Brazil’s vote-counting system was also an important factor.
In many American states, voters use paper ballots, which can slow down counts, and the use of absentee ballots also jumped sharply in 2020 because of the pandemic. The outcome of the election was uncertain for days. By contrast, Brazil is the only country in the world to use a fully digital system without paper backups, which enabled results within hours of the polls closing.
That design was precisely what Mr. Bolsonaro and his allies attacked as a dangerous flaw. They argued that without paper backups, no one could be sure their vote had been counted correctly.
Independent experts agree that paper backups would add assurances, but they also say that multiple layers of security built into the Brazilian system prevent fraud and errors.
As Americans waited nearly a week for the 2020 election to be called for President Biden, Mr. Trump, his allies and pundits on social media capitalized on the delay to sow doubts about voter fraud, using lies and conspiracy theories.
In Brazil on Sunday, nearly every vote was counted in less than three hours. Before 8 p.m. local time, the winner, President-elect Luiz Inácio Lula da Silva, was declared. Mr. Bolsonaro did not explicitly accept the result, but he also did not dispute it.
“The international community has always agreed that the best way to run elections are with timely, transparent outcomes that are announced immediately,” said Pippa Norris, a comparative political scientist at Harvard University who has studied democracies around the world. “Our process is long, extended and poorly regulated.”
In part, the challenge in the United States is that presidential elections are organized around rules and practices that differ by state and even by county. In Brazil, the election is run by one independent electoral court, staffed by a rotating bench of federal judges, that is outside the reach of the executive branch.
Decentralization can be a safeguard against a corrupt power grab because it prevents a single point of failure, while also giving localities the opportunity to introduce rules that expand voting. But the United States is one of the few democracies in the world that does not have a national agency to tally votes and announce results, Ms. Norris said. Instead, the public expects the news media to call elections before official tallies are completed months later.
Yet, in the internet age, even with a smooth election, misinformation can still spread.
On that problem, the U.S. government is largely hands-off, leaving it up to tech companies to police what can be said online, and to identify and remove posts that violate those rules.
In Brazil, one Supreme Court justice has led an aggressive crackdown on misleading and false posts.
The justice, Alexandre de Moraes, who is also Brazil’s current elections chief, ordered tech companies to take down thousands of posts, with little room for appeal, in what he said was a bid to combat “fake news” threatening Brazil’s democracy.
As a result, he became one of the most powerful arbiters in any global democracy of what can be said online. A week before the vote, fellow election officials granted him unilateral power to suspend a tech company in Brazil if it did not comply with his orders to take down a post within two hours.
Misinformation still flowed, but likely far less than if Mr. Moraes had not acted. Yet his forceful approach has drawn broad complaints from Brazil’s right that he, in effect, manipulated the election by censoring conservative voices.
What is clear is that he drastically expanded the power of the Brazilian courts over online speech, and at times, issued decisions that raised concerns over whether his efforts to protect the democracy were instead posing their own threat.
He ordered raids on the homes of eight prominent businessmen after just one of them suggested he supported a coup in a private WhatsApp group, and he jailed five people without trial for posts on social media that he said attacked Brazil’s institutions.
His stern approach creates a tricky debate. Misinformation is a pernicious and fast-moving threat that has led a sizable portion of the country to lose faith in Brazil’s elections.
At the same time, tech companies have repeatedly failed to combat false reports across the world. So when a judge acts assertively to fight the problem — but perhaps sets a dangerous precedent in the process — many in Brazil have mixed feelings.
David Nemer, a University of Virginia professor from Brazil who studies misinformation, said Mr. Moraes’s approach has been effective because he moves quickly and forces tech companies to do better.
“I’m cautiously in favor because of the potential risks,” he said. “However, that should not stop us from having a debate on a more transparent process.”
On Sunday night, it was Mr. Moraes who announced the election results on TV, flanked by 11 other federal officials. “I hope from this election onward, the attacks on the electoral system will finally stop. The delusional speeches, the fraudulent news,” he said.
The crowd gave him a standing ovation and chanted his name.
Minutes later, the White House issued a statement congratulating Mr. da Silva “following free, fair and credible elections” — a sign of support that further impeded any potential effort to deny the results.
A week later, it is clear that an election many had feared posed an existential threat to Brazilian democracy instead proved the strength of Brazil’s institutions — and perhaps even could serve as a model for others.
“We find it very difficult in America to adjust,” Ms. Norris said. “We’re always looking over our shoulder at what the founders intended, as though somehow that’s going to guide us.”
“Really,” she added, “what we need to do is look abroad.”