(Adds Lula comment para 22)

By Anthony Boadle and Leonardo Goy

BRASILIA, March 17 (Reuters) - Former Brazilian President Luiz Inacio Lula da Silva was sworn in as chief of staff to his successor Dilma Rousseff on Thursday as a judge sought to block his appointment and Congress began proceedings to impeach her in a deepening political crisis.

Police used tear gas to disperse hundreds of opposition demonstrators who clashed with Lula's leftist supporters outside the presidential palace where he was sworn in, while ministers and corruption investigators traded barbs throughout the day.

Spontaneous protests also blocked major avenues in Sao Paulo and Rio de Janeiro, spurred by anger that Lula's appointment will shield the former president from prosecutors who charged him with money laundering and fraud as part of a sweeping graft probe centered on state-run oil company Petrobras.

Only Brazil's Supreme Court has jurisdiction in cases against ministers. Shortly after the swearing-in ceremony, a federal judge in Brasilia issued an injunction against Lula's appointment on the grounds it blocked "the free exercise of justice."

Attorney General Jose Eduardo Cardozo vowed to appeal the injunction against Lula joining the government, which he called the decision of a partisan judge.

The standoff inflamed tensions that are already running high between Brazil's executive and judiciary branches, as the Petrobras probe reaches Rousseff's inner circle and hangs over a congressional impeachment committee named on Thursday.

Calls for Rousseff's impeachment have centered on allegations, unrelated to Petrobras, that she broke budget rules to boost spending as she campaigned for re-election in 2014. A 65-member impeachment committee in the lower house of Congress will now study if there are grounds to try her in the Senate.

Rousseff and Lula have both denied any wrongdoing.

Deliberations could drag on for months on the impeachment committee. Seats were spread among all parties in the lower house of Congress, but the key roles of committee president and rapporteur were given to close allies of Speaker Eduardo Cunha, a sworn political enemy of the president.

Brazil's benchmark stock index rallied 6.6 percent, the biggest daily jump in seven years, and the Brazilian real firmed 2.3 percent as the political crisis increased bets that Rousseff's ouster could bring a more market-friendly administration to power.

The real's 10 percent gain so far this month led the central bank to scale back its currency intervention.

Rousseff appointed her mentor, who remains one of Brazil's most influential politicians six years after leaving office, in an effort to fight impeachment and win back working-class supporters amid the worst economic recession in decades.

The corruption probe, however, has weakened Lula's sway in Congress and there are growing signs that Rousseff's main coalition partner is ready to abandon the unpopular government.

"UNDERGROUND WAR"

As Rousseff swore Lula into office, she strongly criticized the release on Wednesday of a taped telephone conversation between them that was made public by Sergio Moro, the crusading federal judge overseeing the Petrobras investigation.

Moro, the public face of the biggest graft probe in Brazilian history, said the tape showed they had discussed influencing prosecutors and courts to protect Lula, who leaves Moro's jurisdiction by joining the government.

"Convulsing Brazilian society with lies, with reprehensible practices violates constitutional rights and as well as the rights of citizens," said Rousseff, who called the recording illegal and anti-democratic.

Judiciary associations and prosecutors working with Moro sprang to his defense, repudiating what they called efforts to intimidate him and his team of investigators.

"Those telephone conversations provide evidence of obstructing the investigation, part of a treacherous underground war waged in the shadows, far from the courts," wrote 13 federal prosecutors on Moro's task force in a public statement.

Moro said in a court filing released on Wednesday that the taped telephone conversations did not provide proof that Lula and Rousseff were interfering with his investigation.

He said, however, that he released the recordings because citizens had a right to know how they were being governed.

One recording, made public by the court, included Rousseff offering to send Lula a copy of his appointment urgently "in case it was necessary" - a possible reference to the ministerial post providing him with immediate immunity from arrest.

In a written statement late on Thursday, Lula pleaded for justice, saying his rights had been trampled by the illegal revelation of his private conversations.

Brazil's biggest-ever corruption probe, which centers on bribes and political kickbacks at Petrobras, has convicted dozens of powerful executives and politicians while recovering 2.9 billion reais ($795 million) in stolen money.

Prosecutors accuse Lula of concealing ownership of an oceanfront apartment that was built and furnished by one of the Petrobras contractors in the graft scheme.

The widening bribery scandal has divided Rousseff's fractious coalition and moved the PMDB party, the largest in Congress, closer to breaking with her government.

Vice President Michel Temer, leader of the PMDB, did not attend the swearing-in of Lula because Rousseff appointed a lawmaker from his party as civil aviation minister, Temer's aides said. A PMDB convention on Saturday banned its members from taking new posts in her government.

($1 = 3.65 Brazilian reais)

(Additional reporting by Caroline Stauffer and Maria Carolina Marcello; Editing by Daniel Flynn, Brad Haynes and Tom Brown)

Our Standards: The Thomson Reuters Trust Principles.