In one of the most momentous days in recent Spanish history, lawmakers in the Catalan regional parliament voted to unilaterally declare independence on Friday, prompting a swift response by the Spanish government, which fired Catalonia's political leaders, dissolved its parliament and called an early election in the region.

Hours after Catalonia's secession move, the Spanish Senate granted the government special constitutional powers to stop the wealthy region's move toward independence.

Spanish Prime Minister Mariano Rajoy's conservative government then called an urgent cabinet meeting. In the evening, Rajoy emerged to announce the emergency measures to prevent Catalan secession, including regional elections called for Dec. 21.

In Barcelona, Catalonia's regional capital, the announcements were greeted with jeers and whistles of disapproval from crowds who had gathered at the gates of the government palace to celebrate their parliament's moves toward independence earlier in the day.

A man holds up a scarf as a crowd of pro-independence supporters gathers in Barcelona on Friday. (Santi Palacios/Associated Press)

"It's not about suspending or meddling in the self-government [of Catalonia), but to return it to normality and legality as soon as possible," Rajoy said in a televised address.

The government and Spain's Constitutional Court had said the secession bid was illegal.

Rajoy also said he was firing the head of the Catalan regional police, shutting down the Catalan government's overseas offices, and dismissing its representatives in Madrid and in Brussels, where the European Union has its headquarters.

After the Catalan parliament voted to back secession, Rajoy said it was a move that "in the opinion of a large majority of people not only goes against the law but is a criminal act."

Pro-independence supporters cheer and wave flags in Barcelona on Friday. (Santi Palacios/Associated Press)

The Senate's decision giving Rajoy special powers trumped the Catalan regional parliament's independence vote, which was doomed because the Constitutional Court has already consistently ruled against any steps toward secession.

The battle around Catalonia's future is far from over, however.

Many Catalans oppose independence

Madrid's move to take away Catalonia's regional powers was sure to be seen as a humiliation and a provocation by Catalans and a backlash was expected, with planned street protests, while regional government workers could follow a policy of disobedience or non-co-operation.

On top of that, the Dec. 21 election could deliver a steadfastly pro-independence Catalan parliament, even if recent polls have suggested the region of 7.5 million people is roughly evenly split on secession.

Many Catalans strongly oppose independence and a group of so-called unionists was organizing a large-scale protest in Barcelona on Sunday.

Holding Spanish flags, demonstrators confront Catalan police as they are prevented from moving forward during a march in downtown Barcelona. (Francisco Seco/Associated Press)

A spokesperson for Spain's prosecutor's office, meanwhile, said the prosecutor would seek to bring rebellion charges against those responsible for the Catalan independence vote.

The tense day, featuring emotional speeches and scenes of joy and despair, went to the heart of Spain's political and cultural history.

The 1978 constitution, drawn up after the end of Gen. Francisco Franco's decades-long dictatorship, created a decentralized Spanish state that devolved power to 17 autonomous regions, including Catalonia. The regions have broad administrative and legal powers. The Spanish Constitution, however, also describes Spain as "indivisible."

Catalan regional government President Carles Puigdemont, right, receives congratulations after the assembly approved the declaration of a unilateral independence. (Alberto Estevez/EPA-EFE)

Catalonia has its own cultural traditions and its own language. Having long seen itself as different from the rest of Spain, the Catalan drive for independence began in 2010 when the Constitutional Court struck down key parts of a groundbreaking charter that would have granted the region greater autonomy and recognized it as a nation within Spain.

Catalonia represents a fifth of Spain's gross domestic product and many want the tax revenues generated by the prosperous region to remain at home.

'Now we are Catalan at last'

The motion to secede was approved by the 135-member Catalan parliament, where secessionists hold a slim majority, with 70 votes in favour. Opposition lawmakers had walked out of the chamber in protest ahead of the vote.

After the vote officials and lawmakers let loose cries of "Freedom!"

In an emotional scene after the vote, regional leader Carles Puigdemont called on cheering fellow separatists to remain peaceful ahead of the crackdown.

"In the days ahead we must keep to our values of pacifism and dignity. It's in our, in your hands, to build the republic," Puigdemont said.

A massive crowd in Barcelona reacts as they watch the parliamentary session on a huge screen. (Emilio Morenatti/Associated Press)

Outside parliament, thousands who had gathered cheered the news, some dancing and raising a toast. In Barcelona, people crowded around TV sets to watch the historic events unfold. The famous Sant Jaume Square outside the regional government office was packed with thousands of people celebrating. Many were draped with the "Estelada" flag that adds a blue triangle to the red and yellow Catalan flag and has become a symbol of the separatist struggle.

"I feel so emotional after the huge fight we went through, we finally got it ... the independence of Catalonia!" said 74-year-old Rosalina Cordera Torelles.

Nearby, 24-year-old Rita Carboneras could hardly contain her excitement.

"I'm super, super, super happy. Super excited," she said. "So relieved. Now we are Catalan at last. We can be ourselves. We are just happy, look everyone around. Everything is so exciting."

The exhilaration was short-lived. Some 500 kilometres to the southwest, the Senate in Madrid voted by an overwhelming margin of 214-47 in favour of granting the government exceptional powers.

'Catalonia is an integral part of Spain'

The main opposition Socialist and pro-business Citizens parties support Rajoy's stance on Catalonia, and many Spaniards outside the region are scornful of Catalonia's secession ambitions.

Rajoy has also received support from outside Spain, with other European leaders, including Germany, France and Britain, rejecting Catalonia's claims. The U.S. administration also backed Rajoy, after President Donald Trump last month branded the Catalan independence ballot as "foolish."

For EU nothing changes. Spain remains our only interlocutor. I hope the Spanish government favours force of argument, not argument of force. —@eucopresident

"Catalonia is an integral part of Spain, and the United States supports the Spanish government's constitutional measures to keep Spain strong and united," U.S. state department spokesperson Heather Nauert said in a statement.

Also supporting Rajoy's warnings of trouble in Catalonia if it forges ahead with its secession bid, more than 1,500 businesses have moved their official headquarters out of Catalonia this month to ensure they can continue operating under European Union laws if Catalonia secedes.

The EU says Catalonia will be tossed out of the bloc if it leaves Spain and would have to apply to become a member, a lengthy process.

When asked about the declaration on Friday in Saint-Bruno-de-Montarville, just east of Montreal, Prime Minister Justin Trudeau said: "Canada recognizes one united Spain."