A Supreme Court judge suspended former Brazilian President Luiz Inacio Lula da Silva's nomination to a Cabinet post amid corruption investigations, a decision likely to stoke tensions in a country already rocked by dueling pro- and anti-government demonstrations.

In his ruling late Friday, Justice Gilmar Mendes called Silva's appointment as current President Dilma Rousseff's chief of staff a clear attempt to help the once wildly popular ex-leader get around his legal woes.

Two weeks ago, Silva was brought in for questioning in a sprawling investigation into an alleged kickback scheme in the state oil company Petrobras. If he becomes a Cabinet minister, Silva can only be prosecuted with the approval of the Supreme Court and his appointment sparked an outcry from critics who said Rousseff was seeking to shield her mentor from prosecution.

"The goal of the falsity is clear: prevent the carrying out of preventative arrest order" against Silva being considered by a lower court, Mendes wrote in his ruling.

Both Rousseff and Silva deny the accusations, and on Friday tens of thousands demonstrators rallied behind Brazil's center-left government. Anti-government protests over the weekend brought an estimated 3 million people onto the streets in nationwide.

Mendes' decision leaves Silva, and Latin America's largest nation, in limbo. The government will surely appeal the decision, which will eventually have to be decided by the full Court. However, with Holy Week next week, it could be some time before the full court meets.

The political turmoil comes as Brazil prepares to host the Summer Olympics in August and Latin America's most populous nation faces crises on several fronts. The country is at the center of an outbreak of the Zika virus, which health experts believe can cause abnormally small heads in newborns. And its economy, long an engine for neighboring countries, has sharply contracted by nearly 4 percent. Inflation has spiked the last year and announcements of job layoffs have become common.

The decision by Mendes was the latest volley in what has become a legal game of ping pong.

Silva was sworn in as chief aide to Rousseff on Thursday, a post that would let the charismatic politician help the president battle an impeachment effort and one that also makes it harder to investigate any possible links to a corruption scandal.

Opponents quickly won injunctions from two regional federal judges to block his appointment, but both were quickly overturned.

Later in the afternoon a federal judge in the city of Assis, Sao Paulo state ordered a third injunction blocking Silva from assuming his Cabinet post.

Supporters of Silva, who was one of the world's most famous leaders as president from 2003 to 2010, rallied in support Friday. Many wore red T-shirts and caps and frequently chanted, "Lula, the minister of hope." The respected Datafolha polling agency estimated 95,000 people took part in the rally, while police estimates put turnout at 80,000.

When Silva appeared on top of a large sound truck to address the crowd he was greeted with loud cheers and shouts of "Lula, Lula."

"Next week, if there is no impediment, I will start to proudly serve President Dilma and the Brazilian people," he said.

"I am going back to help President Dilma do what must be done — re-establish peace and hope. There is no room for hate in this country." He wound up his 20 minute speech staring at the crowd and shouting: "there will be no coup."

Rousseff's supporters say the 70-year-old Silva, known for his ability to build consensus, could save her job and help bring the economy back from the abyss. With her approval ratings in the single digits, Rousseff is fighting against attempts to oust her over allegations of fiscal mismanagement unrelated to the Petrobras case. The move toward impeachment advanced this week as the lower house established a special commission on the matter.

In a public letter Friday, Silva questioned the legality of the surprise release of tapped phone calls between him and a host of prominent public figures, including Rousseff herself.

Judge Sergio Moro, overseeing the Petrobras case, released the recordings late Wednesday, hours after the announcement of Silva's appointment, saying that the taps appeared to suggest attempts to influence judicial officials in Silva's favor.

Rousseff called the recordings illegal and said their release made "clear the attempt to overstep the limits of the democratic state."

In his Friday decision, Mendes also ruled that the investigation into Silva would stay in the hands of Moro. Supporters of Silva and his Workers Party accuse Moro of being on a politically motivated witch hunt, and have tried to get him removed from the case.

____

Prengaman reported from Buenos Aires, Argentina. Associated Press writer Stan Lehman contributed to this report from Sao Paulo.