Spanish PM Mariano Rajoy says he is dissolving the Catalan parliament and calling regional elections over its push for independence.AFP

The Madrid government sacked Catalonia's president and dismissed its parliament on Friday, hours after the region declared itself an independent nation, in Spain's gravest political crisis since the return of democracy four decades ago.

A new election will be held in Catalonia on Dec. 21, Prime Minister Mariano Rajoy said in a televised address on a day of high drama.

As well as removing Carles Puigdemont as head of the autonomous region, he also fired the police chief and said central government ministries would take over the Catalan administration.

"Spain is living through a sad day," Rajoy said. "We believe it is urgent to listen to Catalan citizens, to all of them, so that they can decide their future and nobody can act outside the law on their behalf."

As he spoke thousands of independence supporters packed the Sant Jaume Square in front of the Catalan regional headquarters in Barcelona, their earlier celebratory mood dampened by Rajoy's actions.

In a stunning show of defiance to Madrid, the Catalan parliament had voted in the afternoon to make a unilateral declaration of independence.

Despite the emotions and celebrations inside and outside the building, it was a futile gesture as shortly afterwards the Spanish Senate approved the imposition of direct rule on the autonomous region.

Several European countries, including France and Germany, and the United States also rejected the independence declaration and said they supported Rajoy's efforts to preserve Spain's unity.

The crisis has reached a new and possibly dangerous level as independence supporters have called for a campaign of disobedience. Immediately after news of the Catalan vote, which three opposition parties boycotted, Spanish shares and bonds were sold off, reflecting business concern over the turmoil.

The crisis unfolded after Catalonia held an independence referendum on Oct. 1 which was declared illegal by Madrid. Although it endorsed independence, it drew only a 43 percent turnout as Catalans who oppose independence largely boycotted it.

The independence push has caused deep resentment around Spain. The chaos has also prompted a flight of business from Catalonia and alarmed European leaders who fear the crisis could fan separatist sentiment around the continent.

Catalonia is one of Spain's most prosperous regions and already has a high degree of autonomy. But it has a litany of historic grievances, exacerbated during the 1939-1975 Franco dictatorship, when its culture and politics were suppressed.

In Barcelona, Jordi Cases, 52, a farmer from Lleida province who had driven down with his family for the protest, said he was excited but worried about what came next.

"Now the repression is going to be terrible but we have to take what we can. We must resist and ask for help where needed," he said.