As Catalan leaders held an independence referendum, defying a ruling by the Constitutional Court which had declared it illegal, Spanish PM Mariano Rajoy has abruptly dissolved the Catalan parliament and calling snap local elections after MPs there voted to declare independence.
Rajoy has also fired Catalan leader President Carles Puigdemont and his cabinet. Rajoy also announced the sacking of the Catalan police chief. He said the unprecedented imposition of direct rule on Catalonia was essential to "recover normality".
The head of the local police force has also been removed, Rajoy said, although whether the 17,000-strong Mossos d'Esquadra will take orders from Madrid remains to be seen. Catalan police chief Josep Lluis Trapero and two independence leaders were questioned by a judge in Madrid. They were not charged but the independence leaders were detained.
People of Catalonia have voted 1 October for independence. The final results from the 1 October referendum in the wealthy north-eastern region suggested 90% of the 2.3 million people who voted had backed independence. Turnout was 43%. 90% were in favour of independence. Others boycotted the vote after the court ruling. A motion declaring independence was approved on Friday with 70 in favour, 10 against, and two abstentions in the 135-seat chamber. Several opposition MPs supporting the Madrid rule boycotted the vote.
Thousands celebrated the declaration of independence on the streets of Barcelona, Catalonia's regional capital. As the outcome of the vote became clear, people popped open cava, the local sparkling wine. The same crowds that cheered each Yes vote from Catalan MPs were reportedly booing Rajoy as he made his announcement. There have been pro-unity demonstrations too, with protesters in Barcelona waving Spanish flags and denouncing Catalan independence.
In Madrid many people have begun flying the Spanish national flag from their windows and balconies, to show their support for keeping the country united. There is some sympathy for the Catalan cause, mostly because of the police crackdown during the referendum. But far louder are calls to prosecute those pushing for independence. It's a move which many Spaniards, like their government, are convinced was illegal.
On Friday the Spanish Senate granted President Mariano Rajoy's government the power to impose direct rule on Catalonia, and after an emergency cabinet meeting Rajoy spelled out what that would entail. "The president Carles Puigdemont had the opportunity to return to legality and to call elections," he said. "It is what the majority of the Catalonian people asked for - but he didn't want to do it. So the government of Spain is taking the necessary measures to return to legality." Regional elections, including in Catalonia, arescheduled for 21 December.
After the 1 October referendum, Puigdemont signed a declaration of independence but delayed implementation to allow talks with the Spanish government. He ignored warnings by the Madrid government to cancel the move, prompting Rajoy to first announce his plans to remove Catalan leaders and impose direct rule.
Having been sacked by the federal government in Madrid, Puigdemont has urged supporters to "maintain the momentum" in a peaceful manner. Freedom seeking separatists say the move means they no longer fall under Spanish jurisdiction. But the Spanish Constitutional Court is likely to declare it illegal, while the EU, the USA, the UK, Germany and France all expressed support for Spanish unity.
Spain's prime minister may have hoped warning Catalonia against declaring independence would be enough. Now that Catalonia has declared independence President Mariano Rajoy has to follow through on his pledge to impose direct rule, knowing this is highly risky. Mariano Rajoy argues that Catalan separatists left him no choice. He had to act, to return the region to "legality", as Madrid puts it. But actually doing that will be complex and highly fraught. It's why Rajoy called for calm in Spain, after the Catalan vote for independence. He is acting with broad, cross-party support though, and public backing.
Meanwhile Spanish prosecutors say they will file charges of "rebellion" against Puigdemont next week
Can Catalonia be a soverign nation?
Catalonia looks like it has already got many of the trappings of a state. A parliament, fags, an able leader Carles Puigdemont. The region has its own police force, the Mossos d'Esquadra. It has its own broadcast regulator, and even boasts a series of foreign "missions" - mini embassies that promote trade and investment in Catalonia around the world. Catalonia delivers some public services already - schools and healthcare, for example. There'd be much more to set up in the event of independence, though. Border control, customs, international relations, defence, central bank, Inland revenue, air traffic control, etc.. All of these are currently run by Madrid. There won’t be any problems for Catalonia to launch all these infrastructures.
Catalonia is certainly rich compared with other parts of Spain. It is home to just 16% of the Spanish population, but 19% of its GDP and more than a quarter of Spain's foreign exports. It punches above its weight in terms of tourism too - 18 million of Spain's 75 million tourists chose Catalonia as their primary destination last year, easily the most visited region.
In Spanish "Madrid nos roba" is a popular secessionist slogan - "Madrid is robbing us." The received wisdom is that comparatively wealthy Catalonia pays in more than it gets out of the Spanish state.
Catalonia is one of Spain's richest, most distinctive regions with a high degree of autonomy. But many Catalans feel they pay more to Madrid than they get back, and there are historical grievances, too, in particular Catalonia's treatment under the dictatorship of General Franco. Catalans are divided on the question of independence - an opinion poll earlier this year said 41% were in favour and 49% were opposed to independence.
Carles Puigdemont assumed the office of President of Catalonia in January 2016.He leads the Catalan government. There are 12 ministers, with portfolios including education, health, culture, home affairs and welfare. The Catalan government employs 28,677 people, comprising civil servants and other staff.
Six parties are represented in Catalonia's 135-seat regional parliament. Three of them are pro-independence. Elections were held on 27 September 2015 and "Together for Yes" (JxSí), a coalition of two parties and civic organisations, focused on achieving independence from Spain, won the largest number of seats - 62. It was short of an absolute majority and required support from the pro-independence, anti-capitalist Popular Unity Candidacy (CUP), with 10 seats, to form the government.
The second largest party in the parliament, with 25 seats, is the liberal anti-nationalist Citizens-Party of the Citizenry (Cs). The Socialists' Party of Catalonia (PSC-PSOE), with 16 seats, and the People's Party of Catalonia (PPC), the Catalan affiliate of Spanish Prime Minister Mariano Rajoy's People's Party, with 11 seats, also oppose independence. Catalonia Yes We Can (CSQP), a left wing-green coalition, which won 11 seats, is in favour of self-determination for the Catalan people.
The Catalan parliament, where separatist MPs make up the majority, officially declared independence while the Spanish Senate was meeting to discuss the issue in Madrid on 27 October. Catalan MPs opposed to independence boycotted the vote. The motion called for the transfer of legal power from Spain - a democratic monarchy - to an independent "republic of Catalonia". That means they no longer recognize the Spanish constitution. Within hours, Madrid had responded.
Tarragona has one of Europe's largest chemical hubs. Barcelona is one of the EU's top 20 ports by weight of goods handled. About a third of the working population has some form of tertiary education. It's also true that Catalans pay more in taxes than is spent on their region. In 2014, the last year the Spanish government has figures for, Catalans paid nearly €10bn (£8.9bn) more in taxes than reached their region in public spending. Would an independent Catalonia get the difference back?
Some have argued that even if Catalonia gained a tax boost from independence that might get swallowed up by having to create new public institutions and run them without the same economies of scale.
Perhaps of greater concern is Catalonia's public debt. The Catalan government owes €77bn (£68bn) at the last count, or 35.4% of Catalonia's GDP. Of that, €52bn is owed to the Spanish government. In 2012, the Spanish government set up a special fund to provide cash to the regions, who were unable to borrow money on the international markets after the financial crisis. Catalonia has been by far the biggest beneficiary of this scheme, taking €67bn since it began.
Not only would Catalonia lose access to that scheme, but it would raise the question of how much debt Catalonia would be willing to repay after independence. That question would surely cast a shadow over any negotiations. And on top of the sum owed by the regional government - would Madrid expect Barcelona to shoulder a share of the Spanish national debt?
Economic pressure could slow the process of cessation from Spain Catalonia is a major economic factor now. It accounts for about a fifth of Spain's economic output, but Catalonia also has a huge pile of debt and owes €52bn (£47bn; $61bn) to the Spanish government.
Even though Madrid has powerful economic levers, Catalonia is one of Spain's wealthiest regions. On 5 October a business exodus from Catalonia began. The banks Caixa and Sabadell, along with several utility companies, decided to move their legal headquarters out of Catalonia. Spain has made it easier for businesses to leave and more than 1,600 companies have now copied the banks' move.
Foreign affairs, the armed forces and fiscal policy are the sole responsibility of the Spanish government. The division of powers between the central government in Madrid and the regional government in Barcelona is not as clear-cut as it is in some other countries with devolved authorities such as Germany or the UK.
In the UK, for example, the government in Westminster cannot interfere in Scottish education policy because education is fully devolved. But in Spain, the Spanish constitution takes precedence if there is a clash with any region - something that the Catalan government resents.
Is there still room for compromise?
Not exactly, and neither side appears in the mood for it now. Puigdemont urged international mediation - but there is no sign of that, as Madrid does not want it. The EU - traditionally wary of secessionist movements - sees the crisis as an internal matter for Spain.
In practice, for any region it is very hard to achieve independence under international law. Kosovo discovered that - even though it had a strong case on human rights grounds.
Amid speculation that the Catalan parliament might unilaterally declare independence, some of the region's banks decided to move their legal headquarters to other parts of Spain. Meanwhile, the government in Madrid says any such declaration would have no effect.
The independence movement was galvanized by a 2010 Spanish Constitutional Court ruling which many Catalans saw as a humiliation. The Spanish government could still make a gesture to appease Catalan separatists and calm the situation. That ruling struck down some key parts of Catalonia's 2006 autonomy statute. The court refused to recognize Catalonia as a nation within Spain; ruled that the Catalan language should not take precedence over Spanish in the region; and overruled measures giving Catalonia more financial autonomy.
The court acted after Rajoy’s Popular Party asked it to. Now, to defuse this crisis, Madrid could reinstate the elements of autonomy that were taken from Catalonia.
Prime Minister Mariano Rajoy held a press conference, declaring the rule of law would be restored in Catalonia and announcing Madrid was assuming direct control of the region. He also said the Catalan President Carles Puigdemont and his cabinet had been dismissed, while a snap election has been called for the region on 21 December.
Spain's Senate had already voted to trigger Article 155 of the 1978 constitution - for the first time in Spanish history. It enables Madrid to suspend Catalonia's autonomy.
Spain's Constitutional Court is expected to rule the Catalan independence declaration illegal. The court had already outlawed the vote itself, which took place on 1 October. It is not clear how quickly or effectively Spain can reassert central control over Catalonia. But Article 155 gives the Madrid government authority to act immediately.
As Catalans are deeply divided over independence, Madrid can expect some significant support for its actions in the region. The conservative Rajoy government has the backing of the opposition Socialists (PSOE) in this crisis.
There was widespread anger over the tough methods of Spanish police on polling day. There was video of them dragging some voters away from ballot boxes and hitting them with batons. The volatile atmosphere in Barcelona could explode if Spain adopts such strong-arm tactics to impose its will now.
The economic uncertainty created by the prospect of independence has already led to two banks deciding to move their head offices out of the region. At least part of that uncertainty is over Catalonia's relationship with Europe. Two-thirds of Catalonia's foreign exports go to the EU. It would need to reapply to become a member if it seceded from Spain - it wouldn't get in automatically or immediately. And it would require all EU members to agree - including Spain.
Some in the pro-independence camp feel that Catalonia could settle for single-market membership without joining the EU. Catalans may well be happy to pay for access, and continue to accept free movement of EU citizens across the region's borders. But if Spain chose to, it could make life difficult for an independent Catalonia.
There is also the question of currency. In 2015, the governor of the Bank of Spain warned Catalans independence would cause the region to drop out of the euro automatically, losing access to the European Central Bank.
Normally, new EU member states must apply to join the euro.
They have to meet certain criteria, such as their debt not being too large a percentage of their gross domestic product (GDP). Even if they meet those criteria, a qualified majority of eurozone countries has to approve their entry. In theory, that means even if Catalonia became a new EU member state, it may well take time to rejoin the eurozone - and Spain and its allies could block that. In practice, we just don't know what would happen.
Nobody has ever declared independence from a member of the eurozone then asked to rejoin as a new country. Could Catalonia use the euro without joining the eurozone? It does happen.
Some countries such as San Marino and Vatican City do so with the euro zone’s blessing, since they're too small to ever become EU member states. Others, such as Kosovo and Montenegro, use the euro without the EU's blessing, and so don't have access to the European Central Bank. Again, whether either solution would be practical in Catalonia remains to be seen.
It is the biggest political crisis in Spain for 40 years. Nothing has been seen like it since the end of General Franco's dictatorship. The disputed Catalan independence referendum on 1 October was the trigger, but mutual hostility had been brewing for years. So how could events unfold in Catalonia now?
Parliament in Catalonia has declared independence while the Spanish senate has approved a government proposal to reassert control over the region after its disputed independence referendum. After dismissing the Catalan government and president, The Spanish government put its national media company and police force under the control of Madrid, .
Spain is divided into 17 regions, each with directly elected authorities. Catalonia, in the north-east of the country, has one of the greatest levels of self-government in Spain. It has its own parliament, government and president, police force and public broadcaster.
Catalans have a range of powers in many policy areas from culture and environment to communications, transportation, commerce and public safety.
Spain could opt for incremental steps to suspend Catalonia's autonomous powers, to avoid a huge backlash. The constitution does not specify a time frame for "temporary" direct rule.
With tensions so high it is likely that the separatists will organize strikes, boycotts and more mass rallies in response to Madrid's actions. Their aim will be to put pressure on Madrid to negotiate.
Now that the region would eventually secede, the world focus is concentrated on whether Catalonia would be able to stand on its own two feet. None has rejected the scenario that Catalonia would be able to be strong nation.
Hopefully Spain would adopt a neutral position to let Catalonia cede from it without nay bloodshed and further complications and become an independent nation to be eligible for entry into EU.