Brazil's President Dilma Rousseff (left) talks with former president Luiz Inacio Lula da Silva during the appointment of Lula da Silva as chief of staff, at Planalto palace in Brasilia, Brazil, March 17, 2016. REUTERS/Adriano Machado

The prospect that Brazilian President Dilma Rousseff was on her way out of office cheered financial markets only a few weeks ago, but much has changed in the short time since then. Rousseff, together with her political mentor, former President Luiz Inacio Lula da Silva, are digging in for a fight to the bitter end, suggesting Brazil’s recession-wracked economy will face more hits before the country’s current political crisis is resolved.

On Wednesday, Rousseff appointed Lula -- as the former president is known worldwide -- to be her chief of staff, a job that positions him to pursue the kinds of populist-minded economic policies that he abjured as president, all in the name of preserving the increasingly tenuous grip on power that Rousseff, and the Workers’ Party, still maintains.

Brazil exploded in nationwide protest later in the day as a transcript of a conversation between Rousseff and Lula, the product of prosecutors tapping their phones, appeared to reveal that the goal of his appointment was to afford him a high degree of immunity from prosecution in the corruption scandal that has implicated both the president and her predecessor.

On top of all this Alexandre Tombini, the president of the Brazilian central bank, has threatened to resign if Rousseff executes a policy about-face, according to local media reports, a step which could include selling Brazil’s ample foreign currency reserves and slashing interest rates in a bid to juice short-term economic growth.

“Brazilian assets could fall way more if Lula stays as ‘super minister’ and succeeds in turning economic policies towards more interventionism,” Marcos Casarin, head of Latin America macro services at Oxford Economics, a consultancy.

Brazil’s currency, the real, tumbled for the third straight day as financial markets digested the economic implications of the political turmoil. The turbulence could also scare away foreign direct investment, which has showed signs of a rebound as investors mulled picking up assets on the cheap.

Brazil Overview | FindTheData

While Brazil’s immediate economic woes have been fed by the worldwide bust in commodity prices, which has hit exporters of oil, iron ore and soybeans, its political crisis has emerged as a prosecutors have chipped away at a corruption scandal involving Petrobras, the state oil company.

The steady march of the probe in Rousseff's and Lula's direction has hobbled decision-making on structural changes that could pave the way for renewed economic growth. In about 3 years, prosecutors have obtained at least 40 plea agreements and about 70 convictions, and collected enough evidence to detain Lula, the former president, for questioning and seek his arrest.

News that Rousseff had given Lula protection from immediate arrest by appointing him to her cabinet -- he’s being called a de facto prime minister by Brazilian commentators -- became the spark that led to further protests into Thursday morning. Military police fired tear gas to control crowds in the capital of Brasilia and demonstrations erupted in at least a dozen other cities. Lula was sworn in as chief of staff on Thursday, but soon after a federal judge in Brasilia issued an injunction to suspend the appointment, arguing that it prevents the "free exercise of justice."

A president under political siege can only deepen Brazil’s economic crisis, which saw GDP contract by a harrowing 3.8 percent, a pace that threatens to undo the social gains -- lower poverty, less hunger -- that were Lula’s signature as president. There was some chance that the Brazilian economy would bottom out in the second half of this year, Casarin said. Now, if Rousseff reaches for unorthodox economic tools to ease her political problems, Brazil could face a pounding from financial markets.

“There’s a risk that underneath this bottom there is a trapdoor, which could take us quite a bit further down,” Casarin said.

The country’s northern neighbor, Venezuela, has been a smaller version of what Brazil could face, Casarin said, and Argentina has gone this route before as well. “Every few decades the notion that there is a free lunch to be had pops up in Latin America. But these models become unstable,” he said. “They lead to contraction, inflation and fiscal crisis.”

Constitutional provisions protect Brazilian cabinet ministers from prosecution unless the Supreme Court revokes their immunity. A legacy of efforts to shield elected officials from extra-legal arrest, the rules have now afforded Rousseff the opportunity to hunker down with her mentor, and unveil new economic policies at the toughest moment of her presidency.

There is “momentum building against the top end of government that hasn’t been there previously,” said Simon Whistler, managing director for political and social risk for Latin America at Control Risks, a consultancy. “That said, it is not in Dilma’s nature to go down without a real fight so it’s still too soon to be writing her political obituary just yet, though.”

Rousseff’s motivations appeared clear enough when Sergio Moro, the judge who is spearheading the corruption probe, known as Operation Car Wash, released the results of a wiretap in which the president can be heard telling Lula he could use the document affirming his appointment to her cabinet “only if it is necessary.”

Prosecutors had sought Lula’s arrest on charges of fraud and money laundering in connection the Petrobras scandal, an order that Moro could have issued at any time. After his detention for questioning, Lula denied the accusations, and some supporters rallied to his cause last week.

On the theory that where there is smoke, there is also fire, Brazilians -- resplendent in the brilliant green, blue and yellow of the country’s flag -- poured into the streets over the past weekend by the hundreds of thousands, more than even than during the campaign that forced Brazil’s military government to relinquish power in the 1980s.

The investigation -- “Lava Jato,” in Portuguese -- is wildly popular in Brazil, where the potent combination of young incorruptible prosecutors and a steely judge have channeled the deepest desires of a Brazilian public that is no longer willing to wink at rampant graft.

“I am against any thieves,” reads a popular posting on Facebook in Brazil. “No matter which party.”

A recent poll by the research firm Ideia Inteligência highlights the increasing isolation of Rousseff, and now Lula.

Eighty-nine percent of over 10,000 people surveyed in 82 cities in Brazil supported the Lava Jato investigation. About two-thirds support the impeachment of Rousseff, and a majority felt the detention of Lula was appropriate.

The sheer numbers of Brazilians blanketing the pavement in Rio de Janeiro, Sao Paulo and the capital of Brasilia, and polls like this one, indicate that even Rousseff’s erstwhile supporters are turning on her. That said, the current president’s capacity to hang in there -- she was a leftist rebel, jailed and tortured by the military in her early 20s -- is legendary.

“The situation is now dramatic, with no room for compromise in either side,” said Paulo Sotero, director of the Brazil Institute at the Wilson Center in Washington. “I think Lula is done. So is Dilma. But they won't give up.”

Still, Sotero said the protests will shape the political environment in ways that Rousseff and Lula can’t control. The so-called “Diretas Ja” campaign of 1984 demonstrated that Brazil’s generals had no support left in society, even from wealthier Brazilians who had embraced the military’s ardent anti-communism.

Less than a decade later, in 1992, protests helped topple Fernando Collor de Mello, who resigned shortly before his expected impeachment on corruption charges. Collor is now a member of the Brazilian Senate, and facing his own set of charges related to the Petrobras case.

“Politicians in Brazil,” Sotero said, “understand language of streets.”