“DILMA Out, PT out,” rang the angry chants up and down São Paulo’s Avenida Paulista on a blazing Sunday afternoon on April 12th. They were echoed in towns and cities across Brazil. Yet the demonstrators have already won more than they realise. Less than four months into her second term, President Dilma Rousseff remains in office but for many practical purposes is no longer in power. And the nominally ruling left-wing Workers Party (PT) no longer calls the shots in Brasília, the capital.

Even Ms Rousseff’s tenancy in the Planalto palace is not wholly certain. Thanks to the inflammatory combination of a deteriorating economy and a massive corruption scandal at Petrobras, the state oil company, she is now deeply unpopular. The demonstrators want her impeached, as do 63% of respondents to one recent poll. This week the opposition was receiving legal opinions as to whether she can be impeached, over Petrobras or for violating a fiscal-responsibility law that is supposed to prevent the spending splurge she arranged to get re-elected.

It is an extraordinary comedown. For 12 years the PT dominated Brazil’s politics, thanks to the social policies and rapport with ordinary people of Luiz Inácio Lula da Silva, the president in 2003-10, as well as to windfall growth from a commodity boom that has now ended. Ms Rousseff lacks Lula’s political skills, and their relations are now barely cordial. But still-rising living standards were just enough to win her a second term last October.

Two things have eroded her authority since then. First, the mistakes of her first term have taken Brazil to the brink of a serious recession. Facing the loss of the country’s prized investment-grade credit rating (which would raise the cost of borrowing for firms and households), she appointed Joaquim Levy, a Chicago-trained fiscal hawk, as her finance minister. He is busy cancelling subsidies and cutting handouts—austerity that is anathema to the PT. Ms Rousseff no longer micromanages the economy.

Nor does she command the political agenda. She has lost control of Congress to the Party of the Brazilian Democratic Movement (PMDB), a centrist agglomeration of regional political barons that is the PT’s main coalition partner. The PMDB long complained that the PT hogged the main ministries. Now it has exacted its revenge. Eduardo Cunha, a crafty conservative congressman from Rio de Janeiro, crushed the PT candidate to win for the PMDB the powerful post of Speaker of the lower house. The hyperactive Mr Cunha is pursuing his own agenda. He has claimed the scalps of four ministers in his ten weeks in office, and has jibbed at some of Mr Levy’s fiscal measures. His acolytes call him “prime minister”.

To ease this friction, this month Ms Rousseff fired the PT minister for political co-ordination, handing the job to Michel Temer, her vice-president and the PMDB’s titular leader, and with it the prized power to appoint second-tier officials.

What makes this haemorrhaging of presidential power so dramatic is that Ms Rousseff still has almost four more years in office. In that time the economy will surely get worse before it gets better. Can she survive? Over the past six decades Brazil has seen four different ways in which presidents failed to complete their terms. One president committed suicide. Another resigned. A third was ousted by a military coup, while a fourth was impeached.

Thankfully, it is hard to imagine suicide or a coup. It is also hard to see Ms Rousseff, a tough former urban guerrilla who survived torture, resigning. And Brazilian law holds that a president can be impeached only for political or common crimes committed during her current term of office—though whether that rule would necessarily exempt any malfeasance during her first term is not clear. So far nothing ties Ms Rousseff to corruption; some would like fiscal irresponsibility to be impeachable, but probably it is not. It is for Mr Cunha to decide whether to start impeachment, and he is one of 52 politicians being investigated over alleged illegal donations from Petrobras.

Fernando Henrique Cardoso, a former president who remains the opposition’s intellectual leader, has cautioned that impeachment would be “rashness”. That sounds right. The social movements behind the protests would do better to spend the next three years promoting political reform, pressing for justice to be done in the Petrobras scandal and reinventing a largely moribund opposition. As for the almost friendless Ms Rousseff, she faces a long and dispiriting grind to try to regain the power she has lost. Does she have the fortitude for that?