Exiled former Catalan president Carles Puigdemont, arrested in Italy at Spain's request over an independence referendum that Madrid ruled illegal, was released from prison Friday with no apparent restrictions on his liberty.

Puigdemont, a member of the European Parliament who fled Spain following the 2017 vote, walked out of jail in the Sardinian town of Sassari to cheers from supporters outside.

Former Catalan president Carles Puigdemont is wanted in Spain on allegations of sedition following an attempt to gain independence through a referendum
Former Catalan president Carles Puigdemont is wanted in Spain on allegations of sedition following an attempt to gain independence through a referendum AFP / HATIM KAGHAT

The 58-year-old separatist leader, who spent the night behind bars after being taken into custody Thursday, was free to leave the island but would return for a hearing in October, his lawyer said.

"We always thought this could happen, but we also knew how it could end," a newly liberated Puigdemont told the crowds.

"What happens is that Spain never misses an opportunity to make a fool of itself," he said.

A Catalonian flag displayed outside the court
A Catalonian flag displayed outside the court AFP / Gianni BIDDAU

The court in Sassari will examine an extradition request for Puigdemont on October 4, his lawyer Agostinangelo Marras said.

Marras insists there is no basis for either the arrest or extradition of Puigdemont, who has been based in Brussels in recent years.

Spanish Prime Minister Pedro Sanchez said Friday he would respect the Italian system, but added: "It's clear that Carles Puigdemont must be brought to justice and stand trial."

Several hundred pro-Catalan independence activists demonstrate in front of the Italian consulate in Barcelona
Several hundred pro-Catalan independence activists demonstrate in front of the Italian consulate in Barcelona AFPTV / Aitor De ITURRIA
A Catalonian flag displayed outside the court
A Catalonian flag displayed outside the court AFP / Gianni BIDDAU

The arrest drew a sharp rebuke from the Catalan government, with regional leader Pere Aragones demanding Puigdemont's "immediate release" and saying he would travel to Sardinia to "stand by" him.

It also sparked anger in Catalonia as several hundred pro-independence supporters demonstrated Friday evening outside the Italian consulate in Barcelona, slamming Spanish "repression".

It also comes at a sensitive time, nine days after the left-leaning Spanish government and regional Catalan authorities resumed negotiations to find a solution to Spain's worst political crisis in decades.

Former Catalan president Carles Puigdemont is wanted in Spain on allegations of sedition following an attempt to gain independence through a referendum
Former Catalan president Carles Puigdemont is wanted in Spain on allegations of sedition following an attempt to gain independence through a referendum AFP / HATIM KAGHAT

Ahead of Friday's hearing, supporters gathered outside the court in Sassari, with one holding up a large Catalan independence flag.

And in Catalonia's regional capital Barcelona, hundreds of demonstrators gathered outside the Italian consulate, some holding makeshift signs reading "Freedom" in Catalan over Puigdemont's picture.

Others shouted "Free our president" in Italian and waved Catalan independence flags.

Puigdemont's lawyer Agostinangelo Marras said he "could be released from today"
Puigdemont's lawyer Agostinangelo Marras said he "could be released from today" AFP / Gianni BIDDAU

The October 2017 referendum was staged by Catalonia's separatist regional government despite a ban by Madrid and the process was marred by police violence.

Several weeks later, the separatists issued a short-lived declaration of independence, triggering a huge political crisis with Spain during which Puigdemont and several others fled abroad.

Madrid swiftly moved to prosecute the Catalan separatist leaders that stayed behind, handing nine of them long jail terms.

Although they were all pardoned earlier this year, Madrid still wants Puigdemont and several others to face justice over the secession bid.

In March, the European Parliament rescinded immunity for Puigdemont and two other pro-independence MEPs, a decision that was upheld in July by the EU's General Court.

However, the European Parliament's decision is being appealed and a final ruling by the EU court has yet to be made.

"Somebody misled the (EU) General Court to lift the precautionary measures," Puigdemont's Brussels-based lawyer Gonzalo Boye told AFP.

Aragones, a more moderate separatist who took over as Catalan leader earlier this year, said the only solution to the region's political crisis was "self-determination".

"In the face of persecution and judicial repression, our strongest condemnation. It has to stop," he wrote on Twitter.

And Quim Torra, who had taken over after Puigdemont fled, said his predecessor's extradition to Spain would be "catastrophic" and urged pro-independence activists to be "on high alert".

Meanwhile, the Catalan National Assembly, the region's biggest grassroots separatist movement, has called for protests over Puigdemont's "illegal detention".

Besides Puigdemont, former Catalan regional ministers Toni Comin and Clara Ponsati are also wanted in Spain on allegations of sedition.

"The procedure is entirely left to the judicial authorities," a justice ministry statement said.