BARCELONA — Thousands of people took to the streets for rallies in Madrid and Barcelona on Saturday as Catalan leaders appeared on the verge of announcing a unilateral declaration of independence from Spain, setting up a potential showdown with the national government.
One group of demonstrators in Madrid gathered in a central square to support a united Spain, with many waving Spanish flags. Demonstrators called on both sides to negotiate an end to the crisis.
Elsewhere in Madrid, demonstrators, mostly dressed in white and some carrying white flags, also called for more dialogue between the Catalan and Spanish governments — as did several thousand people in Barcelona, the Catalan capital.
Protestors packed Barcelona’s Sant Jaume Square where the Catalan government has its presidential palace, shouting ‘‘We want to talk!’’ and holding signs saying ‘‘More Negotiation, Less Testosterone!’’ and ‘‘Talk or Resign!’’
‘‘We have to find a new way forward,’’ said Miquel Iceta, the leader of Spain’s Socialist party in Catalonia. ‘‘It’s the moment to listen to the people who are asking for the problem to be solved through an agreement, and without precipitated and unilateral decisions.’’
“What they need is couples therapy!” said Fabian Vazquez, 48, a graphic designer, who stood under a large dove-shaped cardboard display outside Barcelona City Hall.
The demonstrations Saturday followed a week of increasing polarization in Spain, spurred by an independence referendum last Sunday that was held across Catalonia, a region in northeast Spain.
The vote, which had been declared illegal by the Spanish constitutional court, devolved into violent clashes between Spanish national police, who attempted to stop it, and voters. Hundreds were injured, including police officers.
More than 40 percent of Catalan voters took part, with 90 percent casting ballots backing independence.
That led the Catalan regional president, Carles Puigdemont, to announce that he had a mandate to unilaterally declare independence in the coming days.
In response, the constitutional court has barred the Catalan Parliament from meeting Monday, in an apparent effort to stop regional lawmakers from debating the issue.
Another demonstration is set for Barcelona on Sunday to express direct opposition to the Catalan drive for independence.
After the referendum vote and clashes, the Spanish king, Felipe VI, made a rare televised speech to condemn the Catalan leaders. Three Catalan businesses — banks Sabadell and Caixabank, as well as energy company Gas Natural — also announced that they were moving their head offices to other parts of Spain.
Throughout the past week, people in Barcelona have held demonstrations in support of independence, while those in Madrid have gathered in opposition.
But Rita Maestre, a spokeswoman for the local government in Madrid, said most of the rallies Saturday were “proof that between the noise of the polarized extremes there is a large part of the population that wants dialogue.”
Demonstrators in Barcelona carried banners with handwritten slogans such as “Let’s talk!” It was written in both Spanish and Catalan. One called on Puigdemont and Mariano Rajoy, the Spanish prime minister, “to go for a beer.”
“I don’t believe in flags or nationalism because it makes hate and wars,” said Reyes Rodriguez, 25, a publicist in Barcelona. “So I’m here to call for dialogue.”
Rodriguez said Catalans should be able to hold a legal referendum in the future, but argued that the turnout for the Oct. 1 vote had not given Puigdemont a mandate to declare independence.
“A lot of people stayed at home because they felt the vote was illegal and they didn’t believe in it,” Rodriguez said.
Sergi Miquel, a lawmaker from Puigdemont’s center-right party, the Catalan European Democratic Party, said the turnout at the referendum would have been far higher had the police not acted so violently against voters.
“Some people were afraid, I’m sure, and some people could not vote” because the police would not let them, Miquel said.
Representatives of the independence movement said they hoped Puigdemont would follow through with his promise to secede.
Further dialogue is pointless, said Benet Salellas, a member of the Catalan Parliament and a representative of the Popular Unity Candidacy, a far-left group.
“The Spanish kingdom does not want to talk with us and so the only way for the Spanish kingdom to be forced into dialogue with us is to make a declaration of independence,” Salellas said.
The Spanish government had no interest in allowing a legal referendum to happen, leaving Catalonia with no other choice but to secede, Salellas added.
“It’s impossible,” he said. “We tried, I think, 16 times, asking by letter, going to the Spanish Parliament, going to the Spanish constitutional court. In all the ways you can imagine we asked for an agreement for a referendum, and the Spanish state always said no.”
Santi Vila, Catalonia’s regional chief for business, told Cadena SER Radio that he is pushing for ‘‘a new opportunity for dialogue’’ under ‘‘a cease-fire’’ with Spanish authorities.
Vila said he is against Catalonia unilaterally declaring independence at this moment and wants to see a committee of experts from both sides be created to work toward a solution to the political crisis.
Spain’s Minister of Public Works Inigo de la Serna said Saturday more companies will leave Catalonia amid fears over the regional government’s secession plans.
De la Serna told National Public Radio that ‘‘the companies will keep leaving and it’s exclusively the fault of the members of the regional government.’’
Companies are moving their registered addresses to ensure that Catalonia’s possible secession wouldn’t immediately knock them out of the European Union and its lucrative common market.
Europa Press news agency and other Spanish media reported Saturday that Agbar’s board decided to relocate its headquarters to Madrid temporarily until the political conflict in Catalonia is resolved.