By Joe Leahy in São Paulo

Once no strangers to economic crisis themselves, Brazilians in recent months have suddenly landed in the enviable position of being spectators to the follies of the developed world.

Current affairs chat shows on Brazilian television have been abuzz for weeks with discussion of the problems sweeping Europe and the US, from the Washington debt-ceiling standoff to the Greek financial crisis and the News of the World scandal in the UK.

Dilma Rousseff, Brazil’s president, seemed to sum up Brazilian perceptions of an outside world gone crazy last week when she described the debt crises in the US and Europe as “insanity”. The political incapacity of the developed world to find solutions to its problems, she said, posed a “threat” to the global economy.

A struggling emerging market a decade ago, Brazil is today a picture of political and macro-economic stability compared with its once over-bearing partner to the north and the former colonial powers of Europe.

Not only is Brazil now a creditor to the US, with $327bn in foreign currency reserves as of June, the country’s economy is growing steadily and unemployment is at record lows.

Yet, with the developed world showing tendencies once associated with emerging markets, the challenge for Brazil is how to manage its success. It cannot afford to be complacent in the face of the still daunting task of lifting itself out of the middle-income trap in which its economy has been stuck for decades.

The breakthrough for Brazil’s economy came during the 1990s when former president Fernando Henrique Cardoso launched a series of policies aimed at stabilizing consumer prices and the exchange rate.

His successor, former president Luiz Inácio Lula da Silva, continued this focus on macro-economic stability while expanding social programmes to improve the living standards of the very poor.

The results were impressive. Economic growth in Brazil has averaged 4 per cent a year over the past eight years and nearly 49m Brazilians have been lifted into the middle or upper classes.

Brazil has also proven relatively responsible in handling recent challenges. Its economic success has attracted a flood of money from stagnant developed markets, driving up the exchange rate of Brazil’s currency, the real, against the dollar and threatening the competitiveness of local industry.

Brazil’s has responded with the so-called “currency war” – a series of capital and currency controls aimed at curbing this appreciation. But Brazil has mostly resisted pressure from domestic industry to take extreme measures, instead imposing a complex system of taxes designed to discourage short-term hot money flows.

On the fiscal front, Ms Rousseff has sought to rein in a spending splurge during federal elections last year by reducing the proposed size of this year’s budget.

The central bank has also taken the politically difficult decision of increasing Brazil’s already high benchmark rates five times this year to 12.5 per cent to crack down on high inflation. It has coupled these measures with steps aimed at slowing rapid credit growth that some analysts fear is unsustainable.

On the political front, Ms Rousseff has been cleaning out corruption at the transport ministry, firing officials aligned with a coalition partner of her Workers’ Party. Her political troubles have been interpreted by the public as the spring cleaning of a new president.

None of this is to say that Brazil does not have its own challenges. A tight labour market, weak education system and a lack of skilled workers are driving up wages while poor infrastructure is pushing up costs.

Household debt levels are beginning to look unaffordable for borrowers enjoying the fruits of a credit boom. Brazil needs to be careful not to bury its new middle classes under so much debt that when the next economic downturn comes, they will sink back into poverty.

The cost of doing business remains prohibitive, partly because of high taxes and employment costs. And although commodity prices have sky-rocketed, export volumes have not. Brazil has mostly used the bonanza from the global commodity boom to increase the volume of its imports.

Brazil may feel justly proud of itself at the moment. But it will need to remain vigilant to ensure that it does not sow the seeds of the next crisis during the present period of prosperity.