BARCELONA, Spain — 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. Elsewhere in Madrid, other demonstrators, mostly dressed in white and some carrying white flags, called for greater dialogue between the Catalan and Spanish governments — as did several thousand people in Barcelona, the Catalan capital.

“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 on Saturday followed a week of increasing polarization in Spain, spurred by an independence referendum on Oct. 1 that was held across Catalonia, a region in northeast Spain.