LUXEMBOURG (Reuters) - A jailed Catalan separatist leader elected to the European Parliament while in detention had the right to ask lawmakers to decide whether to uphold his immunity, an adviser to the European Court of Justice said on Tuesday.

FILE PHOTO: Former Catalan Vice President Oriol Junqueras testifies before judges during the trial of jailed Catalan separatist leaders at the Supreme Court in Madrid, Spain, February 14, 2019 in this screengrab taken from video. REUTERS/Reuters TV/File Photo

The advice from Advocate General Maciej Szpunar is a boost for the Catalan separatist movement and Oriol Junqueras, who was voted into the European Parliament in May despite being detained in Spain since 2017 after an illegal independence referendum.

Junqueras, the Catalan government’s former deputy leader, was sentenced to 13 years in prison in October.

Szpunar said Junqueras’s conviction had brought his mandate as a European Parliament member (MEP) to an end, but that he had been tried and convicted without the parliament having been given the opportunity to decide on his immunity.

The opinion, if followed by the court, would appear to give Junqueras grounds to challenge his conviction, but it was not clear if it would be enough to overturn it. The court was not immediately available for comment on the implications.

Szpunar advised the court that the parliament should be able to decide whether to waive or defend the immunity of its members.

That immunity means an MEP cannot be subject to detention or legal proceedings because of views expressed or votes cast, although it does not apply to an MEP who has committed an offence.

The Spanish government was not immediately available for comment on the opinion.

The European Court of Justice, the EU’s highest court, is not bound by the advocate generals’ opinions, but judges do tend to follow them in most cases. The court normally gives its verdict within two to four months of the opinion.

After Junqueras was elected in European Parliament elections in May, Spain’s Supreme Court did not allow him to leave prison to take an oath to respect the Spanish constitution, as those elected in Spain are required to do. As he had not taken the oath, the electoral commission declared the seat vacant.

Szpunar said in his opinion that MEPs secured their mandates solely from the electorate and not on any subsequent formality.

His view could also help fellow Catalan separatists Carles Puigdemont and Toni Comin, who were elected as MEPs despite being in exile in Belgium and unable to take up their seats.