The major and most important change on the Brazilian government to achieve this was the LRF - Lei da Responsabilidade Fiscal, "Fiscal Responsibility Law" in English (free translation).
With these law, federal, state and municipal governments, which added much more oversight and control to public spending, requiring budget increases to go through congress, forbidding "money printing" practices and also requiring detailed accounting records to be submitted to a branch of the judiciary (TCU) for approval.
I could go on and write a huge document here, there's a lot of historical questions involved too. If anyone is interested in more details please let me know.