A judge in Brazil has blocked President Dilma Rousseff's plans to appoint her predecessor Luiz Inacio Lula da Silva as chief of staff just hours after he was sworn into the position. Critics of the controversial move say Rousseff was attempting to rescue Lula from a corruption and money-laundering investigation.

Brazil has been gripped by a deepening crisis in the past few weeks with a debilitating recession, mass protests calling for Rousseff's removal, and riots on news that Lula was being approached for reappointment by the government.

And on 16 March high-profile judge Sergio Moro made a taped phone conversation between Rousseff and Lula public. Some people have interpreted the video as proof that Lula was handed the post to shield him from prosecution.

On 17 March, federal Judge Itagiba Catta Preta Neto issued an injunction to suspend Lula's appointment because it prevented the "free exercise of the Judiciary Power, the operation of the Federal Police and of the Federal Prosecutor's Office."

In the South American nation, cabinet members can only be investigated by the Supreme Court, not by federal courts, so his appointment would have halted the probe. The government said they would appeal against the decision.

Last week state prosecutors requested Lula's arrest over charges of money laundering and fraud, accusing the former president of secretly owning a beachside penthouse at the centre of investigations into corruption at state-run oil company Petrobras.

As he prepared to be sworn into his new role, amid much praise from Rousseff, groups of supporters and opponents of the government clashed outside the presidential palace. The 68-year-old Rousseff was the chief of staff for Lula between 2005 and 2010.

During the recording the Belo-Horizonte-born leader was heard saying she offered him the job "just in case of necessity", which is thought to be a reference to the inquiry. She herself is facing impeachment proceedings as the crisis threatens to bring down the establishment.

On Sunday an estimated three million protesters took to the streets in anti-government protests in cities including Rio, Sao Paulo and Brasilia. The probe into operations at Petrobras has already engulfed politicians from all parties as well as prominent business leaders.