(Adds details, background throughout)
By Anthony Boadle and Caroline Stauffer
BRASILIA/SAO PAULO, March 16 (Reuters) - Protests erupted in several Brazilian cities on Wednesday after President Dilma Rousseff named her predecessor Luiz Inacio Lula da Silva chief of staff and a taped conversation fed opposition claims the move was meant to shield Lula from prosecution.
In the capital Brasilia, riot police fired pepper spray at more than 5,000 demonstrators who filled the streets outside the presidential palace and Congress building. They waved banners calling for the leftist leader's resignation and Lula's arrest.
Thousands more demonstrators packed the main Avenue Paulista in Sao Paulo, Brazil's financial hub, which was the center of national protests on Sunday that drew more than 1 million people onto the streets in a call for Rousseff's departure.
With Brazil's economy mired in its worst recession in a generation, popular anger at Rousseff is mounting as an investigation into bribes and political kickbacks at state oil company Petrobras taints her inner circle.
"I am here for the future of my children, grandchildren and great grandchildren," said Vera Carneiro, 75, draped in a yellow-and-green Brazilian flag outside the presidency. "Dilma has to go. She and Lula both. Enough is enough."
Rousseff's appointment of Lula, who was charged last week with money laundering and fraud as part of the probe, was slammed by opposition parties as a desperate attempt to rally support in Congress against impeachment proceedings due to start on Thursday.
Lula, a 70-year-old former union leader whose 2003-2010 government helped lift some 40 million Brazilians out of poverty, remains one of Brazil's most influential politicians.
However, the corruption investigation has weakened his sway in Congress and there are growing signs that Rousseff's main coalition partner is preparing to abandon the government.
"Brazil cannot continue with them anymore," said Rubens Bueno, one of dozens of opposition lawmakers who interrupted a session with chants for Rousseff to resign. "They are using their positions to stay in power at all cost."
The hurried publication of Lula's appointment as Rousseff's chief of staff in a special edition of the government's Official Gazette on Wednesday gave him immunity from all but the Supreme Court, delaying any attempts to prosecute him.
The federal judge overseeing the graft probe said in a court filing released on Wednesday that taped telephone conversations showed Lula and Rousseff considered trying to influence prosecutors and courts in favor of the former president.
He admitted, however, there was no evidence they actually carried this out. One recording, made public by the court, showed Rousseff offering to send Lula a copy of his appointment "in case it was necessary" - a possible reference to it providing him with immunity.
Facing a government backlash against his release of the recordings, Judge Sergio Moro - whose uncompromising tactics have been repeatedly criticized by authorities - said they allowed the public to scrutinize Brazil's leaders.
"Democracy in a free society requires that the governed know what their leaders do, even when they try to act in the protected shadows," he wrote.
GOVERNMENT PROMISES ACTION
Lula's lawyer, Cristiano Zanin Martins, said the decision to release the wiretaps by the court was arbitrary and intended to stir up demonstrations.
The presidential palace said it would take action against the judge and that Lula's swearing in would go ahead as planned on Thursday morning.
Rousseff said Lula was chosen as chief of staff for his experience and that he has a history of championing sound economic policies and fighting inflation.
She said his appointment would not mean he was above investigation as he could be tried by the Supreme Court.
The former president's return to Brasilia was overshadowed on Tuesday by the release of plea bargain testimony from Senator Delcídio do Amaral, who alleged Lula and Rousseff knew about the graft scheme at Petrobras and one of her ministers had tried to buy his silence.
Lula, Rousseff and her ministers have denied any wrongdoing.
Veja magazine reported on Wednesday that Prosecutor-General Rodrigo Janot has decided to request an investigation of Rousseff based on the testimony. Reuters could not immediately confirm the report.
Lula's nomination stirred concern among investors that he might push Rousseff to abandon austerity measures aimed at cutting a fiscal deficit that hit more than 10 percent of GDP last year. Lula has publicly called for more public spending to drag Brazil out of recession.
Credit rating agency Moody's, which downgraded Brazil's debt to junk status last month, said his appointment marked a shift toward political expediency at the expense of fiscal reforms.
Brazil's currency slid as much as 2 percent on Wednesday, and has lost around 6 percent this week as Rousseff's invitation to Lula fed fears of a policy swing. (Additional reporting by Alonso Soto, Lisandra Paraguassy and Maria Carolina Marcello in Brasilia and Guillermo Parra-Bernal in Sao Paulo; Writing by Brad Haynes and Daniel Flynn; Editing by Daniel Flynn and Kieran Murray)
Our Standards: The Thomson Reuters Trust Principles.