* Catalan parliament declares independence
* Senate authorises government to rule Catalonia directly
* Prime minister calls for calm
* Risk of confrontation increases as crisis spirals (adds Britain, France, Germany. Puigdemont quote, court)
BARCELONA/MADRID, Oct 27 (Reuters) - The Spanish government moved to impose direct rule over Catalonia on Friday, stripping the region of its autonomy less than an hour after its parliament declared independence in a stunning show of defiance to Madrid.
Although the Catalan declaration appears to be a doomed gesture, both sides' moves take Spain's worst political crisis in four decades to a new and possibly dangerous level.
Spanish Prime Minister Mariano Rajoy called for calm and said the rule of law would be restored in Catalonia, where secessionists have long cherished the dream of a separate nation.
A crowd of more than 2,000 independence supporters gathered in the Ciutadella Park outside the regional parliament in Barcelona, shouting "Liberty" in Catalan and singing traditional songs as the independence vote went through.
The motion passed in the parliament after a passionate debate from advocates and opponents of independence said Catalonia constituted an independent, sovereign and social democratic state.
Catalan leader Carles Puigdemont left the chamber to shouts of "President!" and mayors who had come from outlying areas brandished their ceremonial batons and sang the Catalan anthem "Els Segadors" (The Reapers).
"Catalonia is and will be a land of freedom. In times of difficulty and in times of celebration. Now more than ever", Puigdemont said on Twitter.
But immediately after news of the vote, which three opposition parties boycotted, Spanish shares and bonds were sold off, reflecting business concern over the turmoil in the wealthy region.
Within an hour, the upper house of Spain's parliament in Madrid authorised Rajoy's government to rule Catalonia directly -- an unprecedented move in Spain since the return of democracy in the late 1970s.
In Brussels, the president of the European Council, Donald Tusk, said the independence vote changed nothing and the EU would only deal with the central government.
The United States, Britain, France and Germany also swiftly dismissed the declaration and expressed support for Rajoy's efforts to keep Spain united.
FIRING THE GOVERNMENT?
Rajoy's cabinet was meeting on Friday evening to adopt the first measures to govern Catalonia. This could include firing the Barcelona government and assuming direct supervision of Catalan police forces.
"Exceptional measures should only be adopted when no other remedy is possible," Spanish Prime Minister Mariano Rajoy said in an address to the Senate on Friday morning.
"In my opinion there is no alternative. The only thing that can be done and should be done is to accept and comply with the law," said Rajoy, who has staked out an uncompromising position.
How direct rule would work on the ground - including the reaction of civil servants and the police - is uncertain. Some independence supporters have promised to mount a campaign of civil disobedience.
The main secessionist group, the Catalan National Assembly, called on civil servants not to follow orders from the Spanish government and urged them to follow "peaceful resistance".
"Tensions are likely to rise significantly over the coming days," Antonio Barroso of Teneo Intelligence said in a note.
"Demonstrators might try to prevent the police from removing Catalan ministers from their offices if the central government decides to do so. This increases the risk of violent clashes with the police."
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 crisis has split Catalonia and caused deep resentment around Spain. National flags now hang from many balconies in the capital in an expression of unity.
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.
The chaos has also prompted a flight of business from region and alarmed European leaders who fear the crisis could fan separatist sentiment around the continent.
"It is not going to be easy, it is not going to be free, it is not going to change in a day. But there is no alternative to a process towards the Catalan Republic," lawmaker Marta Rovira of the Junts pel Si pro-independence alliance said in a debate leading to the vote.
After the debate, lawmakers from members of three main national parties -- the People's Party, the Socialists and Ciudadanos -- walked out. Members of the pro-independence parties and the far-left Podemos then voted 70-10 in favour in a secret ballot aimed at hindering any attempt by Madrid to lay criminal charges on them.
Spain's constitutional court said it was reviewing the vote. The state prosecutor and other parties have three days to open a case.
Montserrat Rectoret, a 61-year-old historian, was among the crowds in Barcelona.
"I am emotional because Catalonia has struggled for 40 years to be independent and finally I can see it," she said. (Additional reporting by Paul Day, Julien Toyer and Jesus Aguado, writing by Angus MacSwan, editing by John Stonestreet)