MADRID — From courtroom battles to noisy street demonstrations, a confrontation between the central government in Madrid and independence movements in the wealthy northeastern Catalonia region has been gripping Spain for weeks.

The conflict is due to come to a head Sunday when Catalonia intends to hold a regional ballot on whether to break away from the rest of Spain, despite government efforts to prevent the vote.

Here is a look at how the standoff has evolved:

____

COURTROOM COMBAT

After Catalan separatists in the region’s parliament passed a law on Sept. 6 to hold a referendum on independence, Spain’s national government said it was illegal and complained to the Constitutional Court. That court ordered the ballot put on ice while its judges deliberate on its legality. They have not ruled yet.

Previous efforts in Catalonia to vote on independence have fallen foul of the Spanish Constitution, which refers in Article 2 to “the indissoluble unity of the Spanish nation, the common and indivisible homeland of all Spaniards.”

As independence supporters defied the Constitutional Court’s decision and continued to prepare the ballot, the state prosecutor in Catalonia filed two lawsuits: one against members of the Catalan parliament for disobedience and abuse of power, and another against members of the Catalan regional government, including regional president Carles Puigdemont, for disobedience, abuse of power and embezzlement. The latter charge carries jail time.

Also, the Constitution’s Article 155 allows the government to suspend, totally or partially, Catalonia’s self-government if the region disobeys a court order.

Spanish police have so far arrested a dozen officials in Catalonia on suspicion of aiding and abetting the vote, triggering large street protests.

____

FOLLOW THE MONEY

Spain’s central authorities have taken over control of virtually all Catalonia’s regional public spending. The aim: to ensure that no tax revenue is diverted to pay for the referendum.

The Spanish government has snatched away from the Catalan government the administration of its spending on health, education, social services and the payment of civil servants. Also, every invoice paid by Catalan authorities, including for non-essential services, must go to Madrid for rubber-stamping before it is paid.

A new system demands weekly public spending reports from Catalan authorities, whereas Spain’s other autonomous regions report monthly.

Tightening the screw, Finance Minister Cristobal Montoro imposed credit restrictions on Catalonia, blocking its government’s access to vital debt funding on international markets.

____

DEFIANT MAYORS

If mayors and their municipalities are unable to help organize the ballot, the independence vote is unlikely to happen.

More than 700 of Catalonia’s about 900 mayors were placed under investigation after saying they would not be intimidated by the state prosecutor’s ban on helping prepare the referendum.

Some of them have appeared before a magistrate and refused to answer questions before being released. They potentially face a ban on holding public office.

The key figure is Barcelona Mayor Ada Colau, who wants a referendum but one that is legal and consented to by the state. Colau is a rising political star in Spain and cannot afford being barred from office. But a crucial one-fifth of the region’s voters are registered in her city.

Concerned about shielding Barcelona’s civil servants from possible prosecution, Colau initially refused to make municipal premises available as polling places. However, she later announced an agreement with the regional government to allow Barcelonans to cast their ballot. She accused Madrid-based central authorities of unprecedented bullying, saying “this is not about independence, it’s about our rights.”

____

THE BIG DAY

Amid so much legal and economic pressure from Madrid, it’s unclear how Catalan authorities will be able to hold the referendum. Whichever way the pro-independence movement has turned, the central government has pounced to block it.

Police confiscated about 10 million ballot papers as well as around 1.3 million posters advertising the referendum. A court order shut down the referendum’s official website, though minutes later the content was replicated through servers overseas.

Ballot boxes and electoral officers will also be needed. The pro-independence movement isn’t saying where they will be coming from.

Meanwhile, authorities hired three ferry vessels to accommodate nearly 5,000 additional police deployed to Catalonia for the vote. The Spanish and Catalan governments are still wrestling over who gives orders to the 17,000-strong regional police force.