Roberto Jefferson had broken the terms of his house arrest when he called Supreme Court Justice Carmen Lucia a “witch” and a “prostitute” in an online attack.
The Federal Supreme Court (STF) had ordered Mr Jefferson to be taken back into custody before the former legislator reportedly barricaded himself in his home in Rio de Janeiro state for eight hours.
Federal Police said Mr Jefferson had resisted arrest using “firearms and explosives”. Two officers were “wounded by shrapnel from a grenade”. They received medical attention and are doing well, police said.
Mr Jefferson was taken into custody in the evening after “an intense negotiation”.
He said in a video posted on social media that he had fired a gun, but that he had not intended to injure the officers.
Mr Bolsonaro immediately condemned the alleged attack by Roberto Jefferson and distanced himself from the former legislator, calling him a “bandit”.
The president, who had earlier sent his justice minister to the scene, renounced the “armed action” and expressed his solidarity with the wounded.
“Whoever shoots at the Federal Police is a bandit,” he said during a television interview on Sunday night, while insisting he had no ties with Mr Jefferson, who in 2020 said the president was his “personal friend.”
Mr Bolsonaro had claimed on social media that he had not taken photos with Mr Jefferson, but several images were later published showing the two together since he became president in 2019.
Mr Bolsonaro condemned the statements made by Mr Jefferson against the Supreme Court justice, but also rejected the STF investigations of Mr Jefferson, which he believes are being carried out “without any support in the Constitution.”
It comes only a week before the presidential election's second round, which pits Mr Bolsonaro against leftist former president Luiz Inacio Lula da Silva.
“The offences against Carmen Lucia cannot be accepted by anyone who respects democracy. They have created a violent faction in society. A machine to destroy democratic values. This generates behaviour like the one we saw today,” Mr Lula wrote on Twitter.