MADRID — Spain’s government on Wednesday moved to block the latest attempt by separatist legislators in Catalonia to re-elect Carles Puigdemont as the region’s leader, even as he fights extradition from Germany.

The government asked Spain’s Constitutional Court to declare invalid a Catalan law approved recently by separatist legislators that could have allowed Mr. Puigdemont to be voted into office in absentia and then read his acceptance speech by videoconference from Germany. After the government’s appeal, the Constitutional Court immediately suspended the Catalan law and warned separatist lawmakers against holding any vote that would violate that order.

Mr. Puigdemont is fighting extradition for trial in Spain while trying to remain the main protagonist in the politics of Catalonia and the standoff with the Spanish government of Prime Minister Mariano Rajoy.

Catalan lawmakers must elect a new leader for their regional government by May 22 to avoid a new election, after months of political deadlock. The standoff followed an election last December, which was called by Mr. Rajoy but failed to deliver the result that he had sought. Instead, the three main separatist parties managed to retain a narrow majority in the regional Parliament, with an almost identical 47.5 percent of the votes that they received in the previous election in 2015.

However, the separatist parties have since been unable to form a government, largely because some of their 70 elected lawmakers were either put in jail in Madrid or fled with Mr. Puigdemont to Belgium in late October, to avoid prosecution in Spain on charges that they led Catalonia toward an unconstitutional secession.

In March, Mr. Puigdemont was detained by the German police while he was traveling by car from Finland back to Belgium. The following month, a German regional judge rejected extraditing Mr. Puigdemont for the crime of rebellion, which carries a prison sentence of as many as 30 years in Spain. However, the judge has not yet decided whether to extradite Mr. Puigdemont for the lesser crime of misusing public money.

Pablo Llarena, the judge from the Spanish Supreme Court who is presiding over the trial against Mr. Puigdemont and other Catalan politicians, has also warned that Spain’s judiciary could take the case before the European Court of Justice if Germany blocks Mr. Puigdemont’s extradition on the charges sought by Madrid. Judge Llarena is also seeking the extradition of Catalan politicians who fled to Scotland, Belgium and Switzerland.

Despite his legal travails, Mr. Puigdemont has maintained his claim to be Catalonia’s rightful leader and has resisted calls by some other separatist politicians to elect a lawmaker who is not among the 25 Catalans who face prosecution on charges of rebellion, sedition or the misuse of public funds.

Mr. Puigdemont has built his case for re-election largely on the outcome of the December vote: His own party won the most seats among the main separatist parties.

Mr. Rajoy is facing pressure within the Spanish Parliament over his handling of the conflict in Catalonia. On Wednesday, Albert Rivera, the leader of Ciudadanos, the party that has allowed Mr. Rajoy to stay in office by supporting his minority government since 2016, said Mr. Rajoy was mishandling Catalonia and “not monitoring the separatists.”

Mr. Rajoy replied by accusing Mr. Rivera of being an “aprovechategui,” an unusual term of Basque origin that essentially means a freeloader.

A version of this article appears in print on , on Page A9 of the New York edition with the headline: Spain Tries To Foil Vote In Catalonia. Order Reprints | Today’s Paper | Subscribe