THINK back eight years, when the prospect of Luiz Inácio Lula da Silva, leader of the left-wing Workers' Party becoming president of Brazil, the world's fourth most populous democracy, caused panic in financial markets. With Lula now preparing to step down after two terms, Brazilians seem poised to elect his chosen successor, Dilma Rousseff. She is at least as left-wing as he is. But the markets' mood could hardly be more different. By way of a pre-election boost, Lula even travelled to São Paulo's stock exchange to hail a $67 billion share issue by Petrobras, the national oil company, to raise funds to develop Brazil's vast new deep-sea fields.

Brazil's circumstances and its standing in the world have been transformed during Lula's presidency and mostly for the better (see article). Poverty has fallen and economic growth has quickened. Brazil is enjoying a virtuous circle: soaring Asian demand for exports from its farms and mines is balanced by a booming domestic market, as—partly thanks to better social policies—some 20m new consumers have emerged from poverty. No wonder foreign businesses are piling in, while a swelling group of Brazilian multinationals is expanding abroad.

Thanks to his tactile charm and impoverished origins, Lula has been an extraordinary salesman for this transformation. He embodies the fairer, more inclusive democracy he has helped to create. His popularity rating stands close to 80%. Barack Obama called him “the most popular politician on earth”. Yet his biggest achievement is not to make his countrymen love him, but to give them continuity. The platform for Brazil's take-off was laid by the liberalising reforms and inflation-busting policies of his predecessor, Fernando Henrique Cardoso. Lula kept these in place when many in his party wanted to scrap them, consolidating economic and political stability.

Hand in hand at the hustings

It is heartening, then, that the election campaign has confirmed a broad consensus on economic and social policy. But there are still big risks ahead, for Lula has left some troubling problems unsolved, and it is not clear whether Ms Rousseff has the strength or desire to tackle them.

As Lula's chief of staff, Ms Rousseff showed herself to be a capable and forceful administrator. She is a tough and courageous woman: as a young leftist militant, she survived torture at the hands of a military regime, and she came through a battle with lymphatic cancer last year. But she has never before held elected office. If she is victorious, it will be thanks not to her personality or achievements, but to Lula's astounding popularity and tireless presence at her side during the campaign (often in violation of electoral law).

Against this, her rivals have struggled. José Serra, until recently the governor of São Paulo, is an experienced and competent politician from Mr Cardoso's party. But his campaign has been woeful. Marina Silva, a former environment minister, espouses many good and thoughtful policies, but her Green Party is new and small. Until a fortnight or so ago, Ms Rousseff seemed assured of outright victory on October 3rd. Then allegations surfaced that her successor as Lula's chief of staff was involved in influence-peddling. Though unproven, this scandal may do enough damage to push Ms Rousseff into a run-off election in a month's time, though it is hard to imagine that she will not, in the end, win.

Let her go

That Ms Rousseff is so dependent on Lula's patronage is a shame, for Brazil needs a strong and independent leader. Success has bred an atmosphere of hubris in Brasília. With the outlook for the world economy so uncertain, that is potentially dangerous. Despite the country's achievements, there are three difficult sets of issues that—assuming she wins—Ms Rousseff will have to deal with.

The first is corruption. The opposition claims that Brazil's new-found oil wealth will foster the elected authoritarianism that grew up in Mexico under the Institutional Revolutionary Party. That looks, for the moment, like an exaggeration; but it is true that the Workers' Party has come to see public office as a perquisite and has a troubling tendency to bloat the federal bureaucracy with political appointees. Fortunately Brazil has a fiercely independent judiciary and media. But Ms Rousseff needs to make a clear commitment to clean government.

The second concerns the role of the state in the economy. This has expanded in Lula's second term, and not only because of the world recession. The government has ill-advisedly given Petrobras a monopoly over developing the new oilfields, and used the share issue to raise its controlling stake in the company. It has lavished cheap loans on firms that it sees as national champions, partly to counteract the strength of the real. But these policies are driving up public debt even as the economy grows. They also crowd out much-needed spending on infrastructure, sanitation, education and innovation. And they do nothing to bring down high interest rates. The next government should aim speedily to eliminate the budget deficit. Better still would be an effort to reform the tax system and relax labour laws that still hold back the economy.

The third test for Ms Rousseff will be in foreign policy. Lula's activism brought benefits to Brazil. But his penchant for autocrats—such as the Castros in Cuba, Venezuela's Hugo Chávez and Iran's Mahmoud Ahmadinejad—damaged the country's reputation as a force for good. The next government will face a particular test in South America, where Brazil has at last become the main engine for regional growth. Mr Chávez's star is waning (see article), but it is far from clear that he will relinquish power voluntarily if defeated in two years' time. Brazil should use its clout to ensure that he does.

That most of these problems are perfectly manageable shows how far Brazil has come. Whether, and at what pace, the country solves them will depend on Ms Rousseff's political skills. For her to acquire the authority to do the job properly, she needs to emerge from Lula's shadow. As his final gift to his country, he should let her do that.