image sourceReutersimage captionMr Bolsonaro has threatened that there will not be elections in 2022 "if they're not free and democratic"
Brazil's President Jair Bolsonaro has suffered a defeat in Congress, after his plan to change the current electronic voting system in elections to one with a paper trail failed.
The proposal fell well short of the three-fifth majority required for a constitutional amendment.
Mr Bolsonaro, who is planning to run for a second term next year, says the current system is open to fraud.
The electoral tribunal has dismissed the allegation as "disinformation".
Critics of the Brazilian leader, dubbed "Trump of the Tropics" during his campaign, say he is using the same tactics as the former US president to allege widespread fraud in case he loses the next election.
President Bolsonaro has for years campaigned for a change to Brazil's electronic voting system, which has been in place for 25 years and which experts say has a solid track record.
On Tuesday, the constitutional amendment to change the system was approved by 229 of the 519 members of the lower house of Congress. It needed 308 to pass.
Brazil's electronic voting system
- Voters cast their ballots electronically at voting stations, there is no paper ballot or print-out
- Electronic voting machines were first used in 1996
- Became the exclusive voting method in 2000
Mr Bolsonaro says there should be a mixed system in which a receipt is printed out for each vote cast electronically.
He argues that a paper trail that can be publicly audited would make fraud more difficult.
After winning the first round of the election in 2018 – but falling short of the votes needed to stave off a second round – he alleged that there had been "problems" with the electronic voting system, which he claimed had robbed him of outright victory.
He did not provide any evidence of the alleged fraud and Brazil's electoral authorities said there were no major problems.
With the presidential elections little more than a year away and Mr Bolsonaro trailing far behind left-wing candidate Luiz Inácio Lula da Silva in the polls, the issue has resurfaced.
In a two-hour Facebook live on 29 July, President Bolsonaro repeated his allegations that past elections had been fraudulent.
In a video message to his supporters on 1 August he went one step further and warned that the 2022 presidential elections would not be held "if they are not clean and democratic".
In the days following his controversial remarks, both the Supreme Court and Brazil's top electoral court ordered that he be investigated over the comments.
image sourceEPAimage captionCritics of the president said a military parade held on the day of the vote was meant to intimidate lawmakers
He has faced additional criticism over a military parade he presided over just hours ahead of the vote in the lower house of Congress.
Opposition lawmakers said the parade was a brazen attempt to intimidate them but Mr Bolsonaro said it had been planned before the vote was scheduled.
It was the first time that tanks rolled past the presidential palace since the end of military rule in 1985.