Barcelona, Spain (CNN) Spain dismissed Catalonia's president and Cabinet, and dissolved its Parliament on Friday hours after lawmakers in the autonomous region defied Madrid and voted to declare independence.

Spanish Prime Minister Mariano Rajoy called new elections and fired the Catalan police chief, as part of an unprecedented package of measures to seize control of the renegade administration in Barcelona.

He said the moves were needed to restore legality, after a political and constitutional crisis that has gripped the country for months.

"In this moment, we need to be serene and careful, but we also need to have confidence that the state has the tools, backed by the law and reason, [to] peacefully and reasonably go back to legality and take away threats to democracy," he said.

Rajoy spoke hours after the Catalan Parliament voted by 70 to 10 to "form the Catalan Republic as an independent and sovereign state."

The day's dramatic and fast-moving events pushed Spain into uncharted territory, testing the limits of the constitution drawn up after the restoration of democracy in the 1970s.

Dramatic scenes in Barcelona

The stage was set when separatists in the Catalan Parliament tabled a motion to declare independence from Spain, arguing that a disputed referendum on October 1 gave them a mandate to split from Madrid.

Supporters of independence gather outside the Catalan Parliament in Barcelona.

After a heated debate, opposition parties walked out of the 135-seat chamber before the vote, some leaving Catalan and Spanish flags on their empty seats.

Pro-independence crowds massed outside the Parliament cheered, jumped up and down, and waved flags, including the Catalan separatist "Estelada" flag, as the independence result was announced.

Visca Catalunya Lliure! #mambo #welcometothecatalanrepublic A post shared by Adrià Mateus (@ams.adri) on Oct 27, 2017 at 6:38am PDT

Less than an hour later, the Spanish Senate granted the Madrid government powers under Article 155 of the Constitution to sack the Catalan President Carles Puigdemont and his ministers.

Rajoy, who has pledged to quash the separatists, called a Cabinet meeting to agree on the measures he would take."Spain is a serious country, a great nation and we will not allow some people to blow up our Constitution," Rajoy told journalists in Madrid.

Urging Spanish citizens to remain calm, he announced that Puigdemont and his ministers would be dismissed, and new elections in Catalonia would be held on December 21.

Spain's Prime Minister Mariano Rajoy has vowed to crush the Catalan independence bid.

The office of Spain's prosecutor general meanwhile confirmed it would file a lawsuit for rebellion against Puigdemont, the Catalan government and the members of the parliament board who voted in favor of independence.

It was unclear on Friday how the Spanish government would enforce the measures announced by Rajoy. A tough crackdown could risk a repeat of the violent scenes that played out in Catalonia on October 1, the day of the referendum.

But it seemed unlikely that members of the Catalan government who have fought so hard for independence for years would simply acquiesce to Spanish government forces. Another question was how the local Catalan police force would react if national forces were deployed to the streets of Barcelona.

Puigdemont: 'Stay strong'

Speaking in the Catalan Parliament building after the landmark vote, Puigdemont said legitimately elected lawmakers had cast their ballots according to a mandate earned in the October 1 referendum.

But he acknowledged that the path ahead would not be easy. "We are facing a period in which we will need to stay strong and in peace, dignified and civil as we have always been, and I'm sure we will keep being so," he said.

Catalan President Carles Puigdemont casts his vote for independence from Spain on Friday.

"The institutions and the people together built nations, societies, and a nation cannot be built without one of these elements."

Supporters followed his words with applause and repeated chants of "freedom, freedom."

International reaction

The European Union has backed Madrid in its handling of the crisis, which Rajoy has insisted is an internal matter.

For EU nothing changes. Spain remains our only interlocutor. I hope the Spanish government favours force of argument, not argument of force. — Donald Tusk (@eucopresident) October 27, 2017

Following the Catalan Parliament's vote, European Council President Donald Tusk tweeted: "For EU nothing changes. Spain remains our only interlocutor. I hope the Spanish government favours force of argument, not argument of force."

Puigdemont responded via Twitter: "Catalans always favour the force of arguments."

The UK and Germany, through government spokesmen, said they would not recognize Catalonia's independence declaration.

French Foreign Minister Jean-Yves Le Drian said his nation does not recognize the declaration of independence.

"France wishes Spain to be strong and united. It only maintains one partner, which is the Madrid government. The constitution of Spain must be respected," Le Drian said in a statement.

The United States also voiced its support for the Madrid government.

"Catalonia is an integral part of Spain, and the United States supports the Spanish government's constitutional measures to keep Spain strong and united," US State Department spokeswoman Heather Nauert said in a statement.

How did we get here?

Several times during its history, Catalonia has found itself caught between the rivalries of France and Spain.

The region industrialized before the rest of Spain and had strong anarchist, socialist and communist movements that all fought against Gen. Francisco Franco in the Spanish Civil War in the 1930s.

The current dispute goes back to that conflict. Franco repressed Catalonia's earlier limited autonomy, and in the early years of the dictatorship at least, expressions of Catalan language and culture. Four years after Franco's 1975 death, the region regained some of that autonomy.

In 2006, Madrid backed Catalonia's calls for even greater powers, granting it "nation" status and financial control. But four years later, the Constitutional Court rescinded that status, ruling that while Catalan is a "nationality," Catalonia itself is not a nation.

One of Spain's 17 autonomous provinces, Catalonia has had its own regional government with considerable powers over health care, education and tax collection. But it pays taxes to Madrid, and pro-independence politicians argue that complex mechanisms for redistributing tax revenue are unfair to wealthier areas, something that has helped stoke resentment.