Spain’s highest court has voided a ban on Catalonia’s pro-independence former leader from standing in the European parliament elections.

Officials at Spain’s electoral commission had said Carles Puigdemont and two other Catalan separatist politicians could not stand because they were not resident in Spain.

The decision is significant because it might allow Mr Puigdemont and his colleagues to ultimately return to Spain under the protection of European parliament legal immunity, if they are elected.

The politicians fled the country on charges of rebellion for their role in Catalonia’s abortive October 2017 unilateral declaration of independence, which was declared illegal by Spanish courts.

The commission had originally imposed the ban after a complaint was raised by two right-of-centre parties, the former governing Partido Popular and the liberal Spanish nationalists Citizens.

But in a unanimous decision over the bank holiday weekend the Supreme Court in Madrid said contesting an election was a “fundamental right” protected by the country’s constitution and that fleeing the country could not make a person ineligible as a candidate.

Protests as Catalan leaders face trial: in pictures Show all 13 1 /13 Protests as Catalan leaders face trial: in pictures Protests as Catalan leaders face trial: in pictures Pro-union protesters demonstrate outside the Supreme Court in Madrid Reuters Protests as Catalan leaders face trial: in pictures A separatist protester holds a sign reading "When injustice becomes law, rebellion is a must" outside the Supreme Court in Madrid AFP/Getty Protests as Catalan leaders face trial: in pictures Separatist protesters hold a banner reading "Nationalism is supremacy" outside the Supreme Court in Madrid EPA Protests as Catalan leaders face trial: in pictures A protester holds a Catalan pro-independence Estelada flag during a protest outside the Supreme Court in Madrid AFP/Getty Protests as Catalan leaders face trial: in pictures A separatist protester holds up a banner during a protest outside the Supreme Court in Madrid Reuters Protests as Catalan leaders face trial: in pictures Basque people hold a sign reading "you will never walk alone, we are with you. Basque Country is always with Catalonia" outside the Supreme Court in Madrid AFP/Getty Protests as Catalan leaders face trial: in pictures Protesters hold banners mocking the trial of jailed Catalan separatists outside the Supreme Court in Madrid AFP/Getty Protests as Catalan leaders face trial: in pictures Separatist protesters hold up signs and banners during a protest outside the Supreme Court in Madrid Reuters Protests as Catalan leaders face trial: in pictures Separatist protesters hold Catalan and Spanish Republican flags and a banner reading "deciding is not a crime" outside the Supreme Court in Madrid Reuters Protests as Catalan leaders face trial: in pictures Pro-union demonstrators hold a sign depicting former President of the Catalan Government Carles Puigdemont reading "Puigdemont not ours" outside the Supreme Court in Madrid Reuters Protests as Catalan leaders face trial: in pictures Pro-union demonstrators hold Spanish flags with the message "hooray for the unity of Spain" outside the Supreme Court in Madrid EPA Protests as Catalan leaders face trial: in pictures Catalan regional president Quim Torra (C-R) and Catalan regional parliament speaker Roger Torrent (C-L) take part in a protest against the trial of jailed Catalan separatists in Madrid AFP/Getty Protests as Catalan leaders face trial: in pictures The president of Catalonian Parliament, Roger Torrent, center, and the Catalan regional President Quim Torra walk with protesters holding a banner that reads "to choose is not a crime" outside the Supreme Court in Madrid AP

When he was selected as a candidate in March Mr Puigdemont had said: “It is time to take another step to internationalise the right to self-determination in Catalonia from the heart of Europe to the whole world.”

He and two other politicians, Toni Comín and Clara Ponsatí, are set to contest the elections for the pro-independence Lliures per Europa list.

MEPs receive parliamentary immunity under EU treaties while going about their duties – meaning that the candidates’ election could allow them to return to Spain without being arrested, if this interpretation is upheld.

However, candidates are not covered by this provision, meaning the trio will not be able to campaign in person in their home country without fear of arrest.

Mr Puigdemont said of the ruling that “there is very good legal work behind each victory achieved”.

Some pro-Catalan independence politicians did not flee the country, or returned – and are currently sitting in jail.