As crowds of protesters converged on the legislature, riot police fired tear gas and stun grenades.
Brazil's Senate approved the cornerstone of an austerity program aimed at putting the country's finances in order, but violent clashes between police and protesters highlighted growing tensions.
The upper house easily passed the measure -- a 20-year government spending freeze -- by 61 to 14 votes. The measure will still have to be put to a second later vote to become law.
"This constitutional amendment is fundamental for controlling public spending," said Senate Speaker Renan Calheiros, a key figure in center-right President Michel Temer's PMDB party.
Temer says the freeze, which he wants followed by even more controversial pension reform and possible cutbacks, is needed to prevent Latin America's biggest economy from bankruptcy.
"People think public money belongs to nobody, but in reality it belongs to us all and we can't spend more than we collect," agreed Senator Jose Reguffe.
But violent scenes outside the Senate in the capital Brasilia underlined fears in some sectors that austerity will just worsen conditions in a society already suffering from a deep recession.
As crowds of protesters converged on the legislature, riot police fired tear gas and stun grenades. Squads of officers occasionally beat and kicked isolated demonstrators.
Some demonstrators hurled objects at police, turning over a car and setting fire to at least two others. Windows were broken at several ministries.
Thick clouds of tear gas eventually drove away the crowd -- estimated by police to reach 10,000 people -- but small groups continued to confront the security forces, throwing back tear gas canisters and attempting to block an avenue.
The tensions came amid national mourning after a plane crash late Monday in Colombia killed much of the southern Brazilian Chapecoense football team and 20 Brazilian journalists, among the more than 70 people who perished.
Flags outside Congress were at half-mast and earlier Temer declared three days of mourning.
In the lower house of Congress, deputies were preparing to vote on a controversial anti-corruption law. The bill would toughen penalties for illegal campaign funds, a major problem in Brazil.
However, there was uproar last week when deputies tried to change the text to include what would have amounted to an amnesty for any politicians who had accepted illegal campaign funds up until now.
In the face of mounting public pressure, Temer announced that he would veto such a bill. But the episode only deepened ordinary Brazilians' distrust of their politicians.
Among the demonstrators was 21-year-old Gabriel Siqueira, who said that austerity would mean stifling his education and hopes for building a future.
"I am an economics student. I have grants but the grants are always being cut. I want to educate myself, to do a master's, but it gets harder and harder to study when they vote for these kind of things," he told AFP outside Congress.
"I hope the senators stop to think a bit about what's happening here before they press the button."
Temer came to power this year after the bruising impeachment of president Dilma Rousseff. Temer has said he has a mandate to move Brazil away from Rousseff's leftist policies, but opponents accuse him of lacking legitimacy.
The latest unemployment figures showed about 12 million people are out of work, or 11.8 percent.
The economy shrank 3.8 percent in 2015 and market estimates are pointing to another slip of almost 3.5 percent in 2016, with weak growth returning next year.