The Spanish government is fighting in the country's top court a motion passed in the Catalan parliament backing independence from Spain.

Prime Minister Mariano Rajoy called the motion a "blatant disregard for the state's institution... they are trying to do away with democracy".

The Constitutional Court is due to decide whether to suspend the Catalan resolution immediately.

The motion asks the regional assembly to aim for independence in 18 months.

Passed on Monday, the motion also gives the assembly 30 days to start legislation on a Catalan constitution, treasury and social security system.

Catalan nationalist parties secured a majority of seats in September elections but fell short of winning half the vote. They had said before the vote that they considered it a de facto referendum on independence from Spain.

Opinion polls suggest a majority of Catalans favour a referendum on independence, but are evenly divided over whether to secede.

Mr Rajoy said, after an emergency cabinet meeting, that he had asked the Constitutional Court to "immediately suspend this resolution and all its effects".

"We're talking about the defence of an entire country. They are trying to liquidate the unity of a nation with more than five centuries of history," he said.

The Constitutional Court is expected to rule against the Catalan motion.

The Spanish government has asked the court to "personally" notify acting Catalan President Artur Mas, his cabinet and the president of the regional assembly, Carme Forcadell, of the consequences should they decide not to abide by the court's ruling.

The pro-secession parties had fully expected Monday's motion to be declared illegal and as part of the motion argued that the court lacks legitimacy.

Two big separatist parties make up the "Together for Yes" ("Junts pel Si") coalition but they needed the help of the far-left CUP (Popular Unity) party to secure an absolute majority in the Catalan parliament.

Artur Mas, who has spearheaded the drive for secession, has been trying to win re-election as Catalonia's president but has failed to secure the approval of the far-left party. The CUP has called for another Together for Yes candidate, Raul Romeva, to take over the leadership role.

Several parties oppose secession in Catalonia, including the Catalan Socialists and Citizens (Ciudadanos), a centre-right party which was born in the north-eastern region but has attracted increasing popularity across Spain.

Its leader, Albert Rivera, said earlier this week: "To those Catalans who want independence: the solution is not to break up the country, it is to reform it."

The rise in tensions between Madrid and Catalonia comes just weeks before Spaniards vote in the general election on 20 December. It is not yet clear who will win the election but every party will want wealthy Catalonia to remain a part of Spain, observers say.

Analysis: BBC's Tom Burridge in Madrid

The stakes have risen. Prime Minister Rajoy's threat to suspend the powers of 21 key political figures in Catalonia, if decisions of the Spanish Constitutional Court are ignored, is the first time Madrid has produced a clear consequence, if the Catalan pro-independence camp continue with their project of trying to break-away from Spain.

Long criticised for inaction, and failing to recognise the determination of Catalan pro-independence parties, the Spanish government knows it has to get the balance right.

With an election looming Mr Rajoy knows he needs to be tough to please Spanish voters. But go too far and he risks antagonising Catalans who want to leave Spain.

So for now, the possibility of Spain trying to seize control of Catalonia's autonomous police force, known as the Mossos, or the prospect of Madrid cutting-off funding to the Catalan Government, known as the Generalitat, are just stories in Spanish newspapers.

But normally, implicit threats in newspapers come from somewhere.

The uncertainty speaks of a political crisis in Spain. No-one quite knows where this will end. The general election on 20 December could change everything.

The left-wing Podemos party is in favour of a referendum. However, the polls suggest Mr Rajoy's party could remain in government and therefore the Catalan crisis might continue.

In Britain, David Cameron made a Scottish gamble and held a referendum, which his side won.

But in Spain, there is not even a debate about whether there should be a referendum in Catalonia. There is a government committed to the unity of Spain, and a rebellion amongst a slim majority of Catalan regional parliamentarians, who are committed to breaking away.