A messy legal battle over the leadership of the Brazilian Football Confederation (CBF) took a new twist Thursday when a Supreme Court judge ordered its ousted president reinstated, after FIFA threatened sanctions over his removal.

The preliminary ruling suspended a lower-court decision and restored the job to Ednaldo Rodrigues, the first black president in the history of the CBF, which has faced a maelstrom of controversy over the legal squabble, the national team's poor performance and a failed bid to sign Real Madrid boss Carlo Ancelotti as coach.

"I hereby suspend the effects of the ruling by the Rio de Janeiro Court of Justice... and order the immediate reinstatement to their positions of the leadership elected by the CBF general assembly of March 23, 2022," judge Gilmar Mendes wrote.

The temporary ruling takes immediate effect, but must now go before the full 11-member Supreme Court.

The lower court's December ruling had thrown out a 2022 deal between the CBF and Rio prosecutors that had paved the way for Rodrigues's election to lead the body until 2026.

It ruled prosecutors and the CBF had overstepped their authority in making the deal.

The case dates back to 2017, when the CBF changed its election rules without consulting representatives of Brazil's top-flight clubs, whose voting power was weakened.

The winner of the ensuing presidential election, Rogerio Caboclo, was sacked from the job in 2021 over sexual harassment accusations -- later thrown out by a judge.

Rodrigues was named his interim replacement.

A Rio court meanwhile annulled Caboclo's election because of the rule change, and Rodrigues won the substitute vote -- the subject of the current dispute.

The lower-court ruling on December 7 removed Rodrigues and named the head of Brazil's Superior Court of Justice for Sport, Jose Perdiz, as interim CBF chief pending new elections, which it ordered him to call within 30 days.

Suspension threat

The court battle has unleashed a swirl of speculation over possible manipulation behind the scenes in Brazil's sometimes corruption-stained football world.

FIFA and the South American Football Confederation (CONMEBOL) had warned the CBF in a series of letters that Brazil could be barred from international competitions if it was shown to be allowing external interference in its affairs, according to Brazilian media reports.

FIFA and CONMEBOL refused to recognize Perdiz as interim president, and said they would send a joint delegation to Brazil from Monday to address the crisis.

"The statutes are clear and conclusive: intervention by external forces is not permitted under any circumstances," a CONMEBOL source told AFP in December.

The ruling comes a day before the deadline to register the Brazilian national team to compete in Olympic qualifiers in Venezuela this month.

Had FIFA and CONMEBOL refused to accept Perdiz's signature on the documents, Brazil could have been excluded from the Olympics in Paris this year.

The judge called that a "risk of imminent damage" in his ruling.

Brazil's participation in 2026 World Cup qualifiers and the upcoming Copa America could also be at risk, as well as Brazilian clubs' participation in international competitions.

The court battle comes at a delicate time for the CBF, which is struggling to restore the Brazilian national team to its glory days amid a string of poor results, including a humiliating three straight losses in their latest World Cup qualifiers.

The five-time world champions are currently a lowly sixth place in the qualifiers, the final automatic qualifying spot from South America.

The CBF has also been left reeling by the snub from Ancelotti, who last month extended his contract with Real Madrid to June 2026.

Rodrigues had led negotiations to sign the four-time Champions League-winning coach to take over the "Selecao."