Judge Fachin underlined that his decision came "in light of recent and unfortunate episodes of political violence."
A Brazil Supreme Court judge has temporarily suspended several provisions implemented by far-right President Jair Bolsonaro that allowed people to buy weapons, citing a "risk of political violence" during the electoral campaign.
"The start of the election campaign exacerbates the risk of political violence," which "makes the need to restrict access to weapons and ammunition extremely and exceptionally urgent," Justice Edson Fachin wrote on Monday.
Fachin said he made the decision "in light of recent and unfortunate episodes of political violence."
He did not specify whether he was referring to local events, such as the July shooting of a Workers' Party (PT) treasurer by a Bolsonaro-supporting police officer, or the attempted assassination in neighboring Argentina on Thursday of Vice President Cristina Kirchner.
According to the court, Fachin's decision establishes that only "people who concretely demonstrate an effective need" can have weapons, one of the rules that Bolsonaro, an enthusiastic backer of gun ownership, had relaxed by decree.
It also determines that purchasing restricted-use firearms should only be allowed for reasons of "public security or national defense, not based on personal interest," as for hunters, sports shooters and collectors, who can buy assault rifles.
That category of gun buyers, which jumped from 117,000 registrations to more than 673,000 under the Bolsonaro administration, is of particular concern to security experts, who fear episodes of violence as the polarised election on October 2 approaches.
The vote pits Bolsonaro against leftist former president Luiz Inacio Lula da Silva.
Lula lead over Bolsonaro ahead of the October election rose to 13 percentage points and widened from 13 to 16 points in an expected second-round run-off, according to a poll published on Monday.
The survey by IPEC showed Lula with 44 percent of voter support against 31 percent for Bolsonaro in the first round of the election scheduled for October 2, compared to 44 percent and 32 percent respectively in the previous poll.
Bolsonaro's constant questioning of the electronic voting system has raised fears that his followers will reject any eventual defeat and could replicate scenes such as the assault on the US Capitol in 2021 after former president Donald Trump lost at the polls.
Monday's decision comes into immediate effect until the full federal Supreme Court concludes its deliberations on the constitutionality of the decrees, which have been suspended for the past year.
Lawyer Bruno Langeani, a member of the NGO Instituto Sou da Paz, told AFP the decision was an "important" one that "indicates an understanding on the part of the Supreme Court that weapons can be a destabilising element in the elections."
Brazil's Superior Electoral Court last week restricted the carrying of weapons in polling stations, in another sign of concern about possible episodes of violence.