By Steve Kingstone
BBC News, Sao Paulo
Statistically, Brazil is one of the most violent places on Earth. Last year, 36,000 people were killed with guns - more than in any other country.
The 'No' campaign portrayed the referendum in terms of civil rights
And yet the Brazilian people have voted in a referendum to reject a proposal to ban the sale of firearms.
So what happened? To outsiders, this referendum looked like a no-brainer.
In a country where one person is killed with a gun every 15 minutes, surely the public would vote in favour of an outright ban on gun sales?
Wrong. By a resounding 64% to 36%, Brazilians decided to keep the gun shops open. The result was more decisive than any poll had predicted.
In explaining the outcome, credit must first be given to the "No" campaign, which mounted a slick but simple critique of the proposed gun ban.
It portrayed the referendum in terms of civil rights, claiming that the government wanted to take away the right of people to choose how best to defend themselves.
It argued that, even if Brazilians did not want a gun, they should defend their right to buy one.
Next, and crucially, the "No" campaign made the point that criminals do not buy guns legally in shops, where customers are subject to strict background checks.
Instead, it pointed to the extensive black market in smuggled weapons, arguing that clandestine firearms would remain untouched by a ban on legal sales.
As a result, millions of voters reached the conclusion that a ban would leave criminals heavily armed, and honest citizens without a lawful means of self-defence.
In opinion polls, that view resonated most with Brazil's educated middle classes, a group that tends to be fearful of crime and lacking faith in the effectiveness of the police.
President Lula seemed strangely lacklustre during the campaign
Without doubt, the "No" campaign worked hard to win the referendum. But at times, the "Yes" campaign seemed to be doing its best to lose it.
As late as September, a clear majority of Brazilians were expressing support for a gun ban.
But the poll lead was squandered by a "Yes" campaign that was heavy in celebrity razzamatazz, and light in penetrating argument.
In their favour, disarmament groups had the recent success of a government-backed firearms amnesty.
Starting in July 2004 the public handed in nearly half a million weapons.
At the same time, the number of gun deaths in Brazil fell by 8%. This was the first such fall in more than a decade, and the statistic drew praise from around the world.
But back home the "Yes" campaign was unable to convince Brazilians that fewer firearms were translating into fewer gun murders.
The government, which supported the proposed ban, must also carry some responsibility for defeat.
Some voters took the opportunity to give President Luiz Inacio Lula da Silva a bloody nose, following the recent corruption scandal in which his governing Workers' Party has admitted to illegal fundraising on a vast scale.
Gun crime kills tens of thousands in Brazil every year
Millions of people who voted for Lula in 2002 feel badly let down.
The president himself seemed strangely lacklustre during the campaign. Previously a strong supporter of disarmament policies, he appeared unwilling to engage in favour a ban on gun sales.
At one point he even refused to confirm to reporters which way he would vote. The impression was of a seasoned politician unwilling to be labelled a loser.
For the foreseeable future, it is unlikely that any government will feel able to revisit the guns issue - such was the deafening volume of the "No" vote.
Brazil is proud of its recently-restored democracy. And rightly or wrongly, the Brazilian people have spoken.