Leader of the Catalonian ERC party Oriol Junqueras. Junqueras demanded "freedom" on Thursday, after the EU's top court ruled he should be recognised as a member of European Parliament with immunity. File photo: AP Photo/Bernat Armangue.

Luxembourg - Jailed Catalan leader Oriol Junqueras demanded "freedom" on Thursday, after the European Union's top court ruled he should be recognised as a member of European Parliament with immunity.

The European Court of Justice said a person who is elected to the EU assembly acquires that status as soon as results are declared, "with the result that he enjoys the immunities guaranteed" for that office.

The immunity "entails lifting any measure of provisional detention imposed prior" to the declaration of the election result, the Luxembourg-based tribunal added.

In reaction, Junqueras tweeted: "Justice has come from Europe. Our rights and those of 2 million citizens who have voted for us have been violated. Annulment of the sentence and freedom for all."

Junqueras was one of nine Catalan separatists sentenced to jail in October for organizing an unauthorized independence referendum in 2017. He received the longest prison sentence: 13 years.

In May, he successfully stood for a European Parliament seat. Spanish judges let him run while he was in pre-trial detention, but refused to release him after the election.

EU judges said that if Spanish courts wanted Junqueras to remain in jail after his election, they should have filed a request to the EU legislature to waive his immunity.

But according to the Europa Press news agency, prosecutors at Spain's supreme court are insisting that Junqueras should remain in jail, and have urged the court to formally strip him of his EU lawmaker status.

European Parliament President David Sassoli called on Spain to heed the ECJ's ruling on Thursday.

If Madrid wants to retain Junqueras in custody once he has taken up his seat, it must "request the withdrawal" of his immunity as soon as possible, he added.

Another appeal for Junqueras' "immediate freedom" came via Twitter from Carles Puigdemont, a former Catalan president also incriminated in connection to the 2017 referendum.

Puigdemont and his ex-health minister Antoni Comin were also elected to the EU assembly and prevented from taking up their seats, and have filed a separate appeal to the EU court.

Puigdemont and Comin are not in a Spanish prison as they fled abroad to avoid arrest, and are currently fighting Spanish extradition requests in Belgium.

Spain maintained that the election of Junqueras, Puigdemont and Comin could not be confirmed until they took an oath in Madrid to respect the Spanish constitution, like other elected EU lawmakers.

Junqueras was not allowed to leave prison to take part in the ceremony, while Puigdemont and Comin refused to fly back to Spain to attend it, for fear of arrest.

The European Parliament initially stood by the position of Spanish authorities, and turned away Puigdemont and Comin when they tried to enter its premises.

Earlier this week, the Belgian court hearing Puigdemont and Comin's extradition cases, as well as that of Luis Puig, a third Catalan politician, postponed the procedure to await the EU court's verdict.

The Catalan issue is one of Spain's most intractable problems.

The region has a separate language and culture from the rest of Spain, but already enjoys a large degree of autonomy from Madrid. Catalans themselves are deeply split on the issue of independence.

Prime Minister designate Pedro Sanchez is currently trying to form a government, and to win a confidence vote in parliament he needs an abstention or the active support of Junqueras' ERC party.