CAMPO GRANDE, the capital of the state of Mato Grosso do Sul, is usually a tranquil place. The state's business is mostly farming, cattle and soyabeans, on flat bushland; city life, as offered by Campo Grande, is clean and rather dull. In recent weeks, however, the state government's offices have had a spate of bomb threats. All were hoaxes, but they seemed intended to tell the governor, Jose Orcirio dos Santos of the left-wing Workers' Party (PT), that he had infuriated some people with his programme to cut spending and reform the state's finances.

Mr Santos—much better known as “Zeca of the PT”—became governor early in 1999 and, at first, behaved as you might expect of a former trade unionist whose party is the main opposition to Brazil's government and its “fiscal adjustment” programme. He promised to “govern for the workers” and gave big pay rises to teachers, health workers and police, taking the state's already precarious finances closer to the brink.

Then, suddenly, he did an about-face, launching a programme to reduce spending while boosting tax collection. The number of political appointees in the state government has been cut in half, to 1,600, and thousands of permanent staff are being offered voluntary retirement. Loss-making state firms have been shut. Tax-dodgers are being pursued more assiduously, over-generous tax breaks to the state's big meat-processing industry are being scaled back, state workers' pension contributions are being raised. As a result, the state's finances have swung from a primary deficit (ie, a deficit even before paying debt interest) to a primary surplus.

Mr Santos—an emphatic man who shouts rather than talks, stabbing his finger, as though he is still addressing one of his union rallies—claims, improbably, that he has always believed in sound finances. But what seems to have forced his conversion is Brazil's new fiscal-responsibility law, which came into force last May. This bans the federal government from bailing out debt-ridden states and cities, as it has done repeatedly in the past; it limits federal, state and municipal borrowing and payroll costs; and it bans politicians from leaving their successors a stack of unpaid bills. Offenders may be banned from office or even jailed.

The governor's example is now being followed by the mayors of the state's 77 municipalities, says Adilson Trindade, political editor of the local Correio do Estado. They are scrambling to comply with the new law, cutting their own and councillors' salaries, exorcising “ghost” workers from the payroll and starting to charge local taxes, instead of simply borrowing or living off transfers from the federal and state governments.

The good behaviour seems to be catching. Since early 1999, when Congress started debating the fiscal-responsibility law, the states have gone from a primary deficit to a primary surplus; and the municipalities have stayed in primary surplus (see chart) even in the approach to last October's local elections, traditionally a time of wild overspending. Raul Velloso, who follows matters of public finance, says most of the improvement has been the result of more efficient tax collection and the higher tax revenues that come with economic growth, as much as of governors' and mayors' efforts to raise taxes. That said, in the past such extra revenue would have been frittered away on grand public monuments and jobs for the boys, not used to stabilise local finances.

Still, such efforts can only be a start, not least because of the burden of debt left behind by previous governors and mayors. In Mato Grosso do Sul, the obsession of Mr Santos's predecessors with grandiose public works (including a $250m, or 500m reais, Palace of Culture with huge expanses of polished granite flooring) have left the state with debts of 4 billion reais, mostly with the federal government. The repayments it makes under a deal with the national treasury are insufficient to cover the interest on the debt, so the lump sum owing continues to rise. Furthermore, the state has another 4 billion reais of unfunded pension liabilities. Mr Santos has started a pension fund, endowing it by selling a few state companies, but it remains far short of what is needed.

The main danger, says Mr Velloso, is that one of the biggest states or cities may get into such a mess that Congress comes under irresistible pressure to rewrite the fiscal-responsibility law. Fortunately, the finances of Sao Paulo state, by far the largest, were stabilised under the six-year governorship of Mario Covas, who died this week. The wobbliest candidates are the states of Rio Grande do Sul and Minas Gerais and the city of Sao Paulo, all governed by left-wing opponents of Brazil's president, Fernando Henrique Cardoso. The governor of Minas Gerais, ex-President Itamar Franco, triggered Brazil's 1999 devaluation by threatening to default on his foreign debt; but after having his federal grants stopped by Mr Cardoso he relented, and has since been paying his bills. Sao Paulo's new mayor, Marta Suplicy, whose incompetent predecessors left 18 billion reais of debts, has so far seemed determined to bring the city's finances under control, conscious that her progress will affect her hopes of running for president in 2006.

Mr Santos insists that Brazil's recent conversion to fiscal rectitude is permanent. “The era of the big-spending state is over,” he says. That really depends on the politicians Brazilians choose to lead them in future. A promising sign, says Mr Trindade, is that in Mato Grosso do Sul, as elsewhere, last October's municipal elections seemed to continue a trend in which voters have rewarded competent mayors and rejected populists. The governor will run again next year and, so far at least, no rival has come forward offering a return to the free-spending past.