RIO DE JANEIRO — The hooded men worked their way through the hallways with a .38-caliber handgun and a machete, shooting at students from point-blank range and hacking at those who tried to get away.

In a country where attacks on schools are rare, there was no one to stop them. The carnage didn’t end until the two attackers shot themselves.

The brutal slaying of five students and two employees at the Professor Raul Brasil State School outside Sao Paulo this month is adding fuel to a debate that’s familiar in the United States: When the shooters opened fire, could a good guy with a gun have limited the losses? Is society safer with fewer firearms or with more?

The bloodbath on March 13, one of the worst mass shootings in Brazil’s history, comes as new President Jair Bolsonaro begins to loosen restrictions on gun ownership.

A 2003 disarmament law effectively prevented most Brazilians from buying guns. Bolsonaro argues that firearms could help law-abiding citizens defend themselves.

Gun rights advocates here say the school attack proves his point.

In grainy security footage, as students and teachers collapse into pools of their blood, the advocates see helpless victims who might have been able to stop the massacre if they had been armed.

“Another tragedy propagated by minors that speaks to the unfortunate disarmament law, still in place,” Bolsonaro’s son Flavio, a senator from Rio de Janeiro, tweeted hours after the shooting.

Another senator from Bolsonaro’s party said that if teachers had been armed, the attack could have been stopped. On the day of the shootings, Brazilian lawmakers introduced legislation to make it easier to manufacture guns in the country.

Mass shootings remain rare in Latin America’s largest country, and school shootings are rarer still. But gun violence is rampant.

Almost 64,000 people were killed in Brazil in 2017, the most recent year for which figures are available. That was nearly four times the number in the United States.

Bolsonaro, a longtime gun rights advocate, became known during the presidential campaign last year for posing with his fingers in the shape of a pistol. Since suffering a stabbing attack on the campaign trail, the former army captain says he sleeps with a gun under his pillow — now in the presidential palace.

The 2003 law requires citizens who want to purchase a gun to prove that they need it — and to get the police to agree.

During Bolsonaro’s first month in office, he signed a decree that limited the cases in which police could reject their applications.

“This is so good citizens can at this first moment have peace inside their homes,” Bolsonaro said. He said more measures could follow.

The decree has boosted interest among Brazilians eager to arm themselves.

At a gun range in Rio de Janeiro, shooting instructor Anderson Moreno showed students how to aim for the chest.

Laudine Roque, 27, wiped her hands on her jeans before pulling the trigger of her handgun. She lives in Campo Grande, a neighborhood with one of the highest homicide rates in Rio. She says several of her neighbors have had break-ins.

“I don’t want to be next,” she said.

The Olympic Golf Course in the affluent Barra da Tijuca neighborhood of Rio de Janeiro is set to open a state-of-the-art gun range this year to cater to anxious millionaires.

Owner Axl Satier already operates two ranges and gun shops in Rio de Janeiro state.

“We are businessmen, and this is a good opportunity,” he said.

Satier hopes members will soon be able to add .38-caliber guns to their clubs. The day after Bolsonaro signed his decree, a line of customers waited outside one of Satier’s stores for it to open. He sold out of ammunition in the first week.

“Bolsonaro’s election has opened a new space in the market,” he said.

Critics say more guns will lead to more killings, as some end up being used by people who are poorly trained and ill-equipped to handle them.

Police have not determined how the gun from this month’s shooting was obtained. Of the eight school shootings in Brazil since 2002, half involved guns obtained at home, the Sou da Paz Institute reported.

Sou da Paz — “I come in peace” — works to reduce violence in Brazil.

“The sense of insecurity, the fear Brazilians have of violence and crime, increases the possibility of events like this,” Executive Director Ivan Marques said.

“The people who purchased the gun may have been well-intentioned,” he said. “But ultimately, it’s one more gun in circulation that can become available for these kinds of atrocities.”