Brazil's upper house voted 53 to 16 to lock in a spending freeze for a 20-year period billed as the centerpiece of austerity reforms in the country.
Center-right President Michel Temer says tough measures are needed to get Brazil's finances back under control, but his austerity policies have prompted violent protests and were criticized last week by a UN expert as "a historic mistake."
Police were out in force in the capital Brasilia to protect government buildings from demonstrators during the upper house vote. An expected protest had not materialized before the Senate rapidly wrapped up its debate.
The vote means that the spending cap is now mandated by the constitution, serving as the central plank in Temer's bid to "transform" the broken economy, which is in deep recession.
However, Temer is rapidly losing political clout as he and many of his senior allies fight to survive a slew of corruption allegations.
Brazilians battered by nearly 12 percent unemployment and stubbornly high inflation are increasingly angry over the scandals and hostile to the austerity measures.
A poll published Tuesday showed that 60 percent of Brazilians oppose the spending ceiling. Only 24 percent are in favor, the Datafolha poll published in Folha newspaper said.
When the Senate held a first vote on the measure two weeks ago, protesters fought riot police outside Congress, burning cars and smashing windows.
Early Tuesday, police in the capital restricted access to the area around Congress and said they had confiscated supplies of masks that protesters were planning to wear in case of tear gas.
There have also been violent clashes recently in Rio de Janeiro where less than four months after hosting the Olympic Games, the nearly bankrupt state government is pushing through its own spending cuts and tax hikes.
Businesses in the neighborhood of the local legislature have boarded up their windows in anticipation of more trouble this week.
Temer, in an attempt to claw back public support, has unveiled stimulus measures that would attempt to give a short term boost to the ailing economy, the largest in Latin America.
But as the Senate began debating he defended his far-reaching austerity proposals, saying they were needed to change Brazil for the long term.
In addition to the spending ceiling, a separate measure is being submitted to Congress proposing pension reforms. At the center of the measure would be a minimum retirement age of 65, substantially higher than the current requirement, which varies widely between professions, but can be as early as 55 years old.
"We need a lot of courage at this moment in Brazil to do things that are apparently unpopular but which will bring popularity later," he said in a statement.
"We need to transform the country," he said.
Philip Alston, the UN poverty and human rights rapporteur, attacked the 20-year spending cap as "putting an entire generation at risk of social protection standards well below those currently in place."
"This is a radical measure, lacking in all nuance and compassion," he said last week. "It will hit the poorest and most vulnerable Brazilians the hardest."
Temer's entire government is struggling in the face of allegations tying senior figures and the president himself to the giant embezzlement and bribery probe centered on state oil company Petrobras.
Temer came to power last August after the impeachment of leftist president Dilma Rousseff. As her former vice president, Temer was appointed to the post automatically for the rest of her term through 2018.
Temer said he would focus on ending the political and economic chaos that had doomed the Rousseff government.
However, the latest poll from Datafolha shows 63 percent of Brazilians want him to resign to allow early elections. Only 10 percent said they thought his government is doing a good job.