Here's a timeline and key events of the northern region's separatist crisis:
On September 6, 2017, the separatist majority in Catalonia's regional parliament passes a law paving the way for an independence referendum on October 1.
It is fiercely opposed by Madrid. In February 2017, Spain's Constitutional Court had declared such a vote would be unconstitutional.
On October 1, security forces operating under a judicial mandate intervene in the referendum process, seizing ballot boxes in many polling stations.
Images of police violence are beamed around the world.
Turnout is about 43 percent, with nine out of 10 voters backing independence, Catalan authorities say. The results cannot be verified, as there are no independent observers and police disrupted the electronic count.
On October 3, after hundreds of thousands of Catalans rally in fury over police violence against voters, King Felipe VI sternly denounces the independence bid, and calls on national authorities to “ensure constitutional order”.
On October 27, 70 separatist deputies — just over half of the 135 lawmakers in the Catalan parliament — unilaterally declare independence.
The central government immediately suspends Catalonia's autonomy, dissolving its parliament and dismissing its separatist leaders. It calls a regional election for December 21.
Madrid gets tough
On November 2, 2017 eight regional ministers are detained. A European arrest warrant is issued for Catalan regional president Carles Puigdemont, who has fled to Brussels.
Catalans turn out in large numbers during a December 21 regional election, voting separatist parties back into power, including several candidates who are in prison and others who in self-imposed exile.
On June 2, 2018 Quim Torra is sworn in as Catalonia's new president and the region's autonomy is restored.
That same day a new Spanish prime minister, Socialist Pedro Sanchez, is sworn in.
He adopts a softer tone on Catalonia — resuming dialogue with Torra — but rules out any referendum on independence.
Talks between Sanchez and Torra break down ahead of the start on February 12, 2019 of the trial of 12 separatists for their role in the independence bid.
On October 14, the Supreme Court hands down heavy prison sentences of between nine and 13 years to nine of the separatists, who are convicted of sedition.
Sanchez says it is time to “turn the page” in relations with Catalonia and focus on “dialogue”.
Thousands of Catalans react to the sentences by pouring into the streets in protest, blocking roads and rail tracks and trying to paralyse Barcelona's airport.
Catalonia is rocked as separatists burn barricades and clash with riot police.
Sanchez is sworn in for a second term in January 2020 with the support of Catalan separatist party ERC.
The party agreed to back him in exchange for the start of talks between Madrid and Catalonia's regional government over the secession crisis.
The talks begin on February 26 but are soon suspended due to the pandemic.
Torra in September 2020 is banned from holding public office for refusing to remove separatist symbols from public buildings, triggering Sunday's early election in Catalonia.