Catalonia’s independence movement claimed victory in the region’s election with parties seeking secession set to gain an overall majority in parliament; a dramatic and unexpected result that will have huge impact not just on Spain, but the European Union.

The outcome is a shattering blow to Mariano Rajoy, who had called the election with the expectation of reaffirming Madrid’s control over Catalonia with an emphatic victory.

The Spanish Prime Minister instead now faces the probability of an ongoing confrontation with a separatist coalition once again in power in Barcelona.

The three separatist parties, Esquerra Republicana (ERC) and Junts Per Catalunya (JxCat) and the CUP have the numbers required to reach 70 seats: two more than necessary for a majority.

The pro-unionist Ciudadnos may end up as the single largest party, but adding to Mr Rajoy’s travails, his Popular Party (PP) has performed very poorly.

JxCat is expected to get 34 seats; ERC 32 and the CUP 4. Ciudadnos is due to get 36 seats: the Catalan Socialist party 17; the anti-austerity Comu-Poden 8 and the People’s Party 4.

Late on Thursday, JxCAt – led by deposed Catalan president Carles Puigdemont – claimed victory and demanded the release of political prisoners.

“The Spanish state has been defeated,” Mr Puigdemont said, without saying if he would return to Spain. “Mariano Rajoy has received a slap in the face from Catalonia.”

The Spanish Prime Minister will now face pressure and critical scrutiny, not just for gambling on the snap election, but for his heavy-handed response to Mr Puigdemont’s Catalan government calling for an independence referendum; the Guardia Civil were sent in, and clashes broke out injuring hundreds of people.

Catalonia election: in pictures Show all 9 1 /9 Catalonia election: in pictures Catalonia election: in pictures People react to results in Catalonia's regional elections at a gathering of the Catalan National Assembly REUTERS Catalonia election: in pictures Ousted Catalan leader Carles Puigdemont and former Catalan Health Minister Antoni Comin, left, gesture during a press conference Rex Features Catalonia election: in pictures Center-right party Ciudadanos (Citizens) candidate Ines Arrimadas (C) and the rest of candidates and party members celebrate their polls results AFP/Getty Images Catalonia election: in pictures Suporters of Ciudadanos party celebrate the results EPA Catalonia election: in pictures Former Catalan regional minister Jordi Turull (C), candidate of Catalan pro-independence party Junts per Catalunya, and former Catalan regional minister Josep Rull, candidate of Junts per Catalunya celebrate the results Rex Features Catalonia election: in pictures Catalan independence supporters celebrate AP Catalonia election: in pictures Candidate of Ciudadanos party to the Catalan regional elections, Ines Arrimadas (C), next to the party leader, Albert Rivera (behind), delivers her speech as they celebrate the results EPA Catalonia election: in pictures Catalan independence supporters celebrate at the Catalan National Assembly headquarters after results of the regional elections in Barcelona AP Catalonia election: in pictures Junts Per Catalunya supporters celebrate following the Catalan regional election Getty Images

Anger at the violence, as well as the subsequent jailing by Spanish courts of Catalan political leaders, bolstered support for the pro-independence parties and polarised opinion.

This paved the way for a bitter and acrimonious campaign, during which the separatists repeatedly highlighted what they charged was state repression reminiscent of the time of Franco.

A record turnout of over 80 per cent of the electorate – 5 per cent more than the previous election two years ago – was, according to many analysts, expected to help the unionists, with those who did not vote in the referendum on 1 October (declared illegal by the Rajoy government) going to the polls.

But the increased numbers had, in fact, helped the separatists.

The possibility still remains that Ciudadnos, as the largest single party, will demand the first option to form a government.

However, with votes slipping away, it is left with the prospect of setting up a minority administration which is certain to face popular discontent.

The voting in this extraordinary election took place while Mr Puigdemont is in exile in Belgium, with an arrest warrant issued against him by the Madrid government of Mr Rajoy, and while ERC head Oriol Junqueras is in a Spanish jail.

As the news of separatist success began to emerge, an aide to Mr Puigdemont sent a WhatsApp message saying: “As you see, we are the comeback kids.”

Mr Puigdemont had tweeted from Brussels in the morning: “Today we will demonstrate the strength of an indomitable people. May the spirit of 1st October guide us always.” He added later that “this is not a normal day for democracy”.

He has not been able to vote, as he would have had to go into the Spanish embassy in Brussels to do so.

Mr Junqueras said he had sent a postal vote from prison. He sent a note to his wife saying, “Today I wish to be with you and the children for more reasons than ever.” The couple will spend their fourth wedding anniversary apart because of his incarceration.

Catalan independence supporters toast as they celebrate results of the regional elections in Barcelona (AP)

At the final rally of JxCat, Mr Puigdemont had given a speech on a video link from Brussels. Nine seats on the front row were left empty with names of jailed Catalan leaders attached, including Mr Junqueras of ERC.

But the two parties have failed to agree to a joint ticket, as they had done in the previous regional election two years ago, and their leaders have been exchanging barbs.

“I went to prison because I do not hide and I am consistent with my acts,” said Mr Junqueras in a radio interview. Mr Puigdemont’s response was: “I am in Belgium because I also do not hide and I am consistent.”

But JxCat and ERC leaders will face great pressure from their supporters to form a coalition. The mood among many was echoed at a polling station in L’Hospitalet de Llobregat, a Barcelona suburb, by Bernat Oliveras, who appealed for the two leaders to bury their differences and work together.

“This is a great opportunity: a moment in history for the struggle for independence to be united. It would be really, really irresponsible to let this slip away because of any personal problems people have with each other. The people will never forget this if it happens,” said Mr Oliveras, who had voted for JxCat.

At the town of Arenys de Munt, where a referendum held eight years ago is viewed as the start of the current struggle for independence, chief of council operations Josep Sanchez Camps stated: “I really do worry if we fail to form a government, and our opponents like the Peoples Party and the Socialists form one instead. The cause of freedom may be lost for years.”

Raquel Santiago, volunteering for the ERC in central Barcelona, described how the violence on the day of the referendum had boosted the backing for independence.

She works for the Catalan Fire Service whose members, helping at the polling stations, were attacked by some of the Guardia Civil officers.