Spanish Prime Minister Mariano Rajoy said he would not rule out using the constitutional powers to remove Catalonia's autonomous status if it claimed independence as tens of thousands took to the streets to call for talks.

The wealthy northeastern region of Catalonia, with its own language and culture, held a referendum on 1 October on independence, in defiance of the Spanish constitutional court which had ruled the vote illegal.

Until now, Mr Rajoy has remained vague on whether he would use article 155, the so-called nuclear option, of the constitution which enables him to sack the regional government and call a fresh local election.

In an interview with Spanish newspaper El Pais Mr Rajoy was asked if he was ready to trigger the article 155 of the constitution, and said: "I don't rule out absolutely anything that is within the law... Ideally, it shouldn't be necessary to implement extreme solutions but for that not to happen things would have to be changed."

Tens of thousands of people gathered across Spain as Catalonia prepared to declare independence from the rest of the country, many dressed in white and calling for talks to defuse Spain's worst political crisis for decades.

The Catalan authorities say around 90 percent of those who voted supported a split from Spain. Madrid says secession is illegal under the Spain's 1978 constitution. Residents of Catalonia who oppose secession largely boycotted the vote.

The crisis is a political test for Mr Rajoy, who has been uncompromising. Some 900 people were injured during the vote when police tried to disrupt voting, firing rubber bullets and charging crowds with truncheons.

The political stand-off has divided the country, pushed banks and companies to move their headquarters outside Catalonia and shaken market confidence in the Spanish economy, prompting calls from the European Commission for Catalan and Spanish leaders to find a political solution.

"I hope that the Catalonia that makes pacts, is moderate and for many years contributed to Spain's economic growth and improvement in welfare and wealth returns. It can't be in the hands of extremists, the radicals and the (far-left secessionist party) CUP," he said.

However, he ruled out using mediators to resolve the crisis and also said the issue would not force a snap national election.

The Catalonia crisis explained in 60 seconds

In peaceful protests called across 50 Spanish cities on Saturday morning, thousands gathered dressed in white and carrying banners calling for peace and dialogue between leaders.

In Barcelona, protesters chanted "let's talk" in Catalan, while many carried signs criticising political leaders for not finding a diplomatic solution to the impasse.

"This is producing a social rupture in Catalonia and this has to be resolved through dialogue, never via unilateralism," Jose Manuel Garcia, 61, an economist who attended the protest dressed in white said. I'm very worried. This will end badly and everyone will lose (without dialogue)."

While Catalan leader Carles Puigdemont has said he is open to mediation, Rajoy has demanded he give up the independence campaign before discussions can be held.

In Madrid thousands gathered beneath the enormous Spanish flag in Colon Plaza waving their own flags, singing and chanting "Viva EspaÃ±a" and "Viva Catalonia".

"I've come because I feel very Spanish and makes me very sad what's happened," said Rosa Borras, 47, an unemployed secretary who had joined a noisy gathering in central Madrid.

Ms Borras, wearing a "Catalonia, we love you" sticker and surrounded by thousands waving Spanish flags, added: "I wanted to be here for unity, because I also feel very Catalan. My family lives in Catalonia."

Mr Rajoy's government mobilised thousands of national police to stop last Sunday's vote, leading to clashes with would-be voters as they tried to close polling stations in schools and remove ballot boxes.

In the El Pais interview, Mr Rajoy said the around 4,000 extra police shipped in to the region would stay until the conflict had been resolved.

The police violence drew widespread condemnation and forced the government to issue an apology on Friday, although tensions continued to rise after reports of plans for the Catalan parliament to vote on a unilateral declaration of independence on Tuesday.

Catalonia independence referendum: Riot police clash with voters Show all 17 1 /17 Catalonia independence referendum: Riot police clash with voters Catalonia independence referendum: Riot police clash with voters A man faces off Spanish Civil Guards outside a polling station in Sant Julia de Ramis Reuters Catalonia independence referendum: Riot police clash with voters Riot police form a security cordon around the Ramon Llull school in Barcelona EPA Catalonia independence referendum: Riot police clash with voters Riot police evict a young woman during clashes between people gathered outside the Ramon Llull school in Barcelona EPA Catalonia independence referendum: Riot police clash with voters Spanish Civil Guard officers break through a door at a polling station in Sant Julia de Ramis Reuters Catalonia independence referendum: Riot police clash with voters Spanish National Police clash with pro-referendum supporters in Barcelona on Sunday AP Catalonia independence referendum: Riot police clash with voters Crowds raise their arms up as police move in on members of the public gathered outside to prevent them from voting in the referendum at a polling station where the President Carles Puigdemunt will vote later today Getty Catalonia independence referendum: Riot police clash with voters People confront Spanish Civil Guard officers outside a polling station Reuters Catalonia independence referendum: Riot police clash with voters Three man hold each other as they try to block a Spanish police van from approaching a polling station AP Catalonia independence referendum: Riot police clash with voters A woman shows a ballot to a Spanish Civil Guard officer outside a polling station Reuters Catalonia independence referendum: Riot police clash with voters A man wearing a shirt with an Estelada (Catalan separatist flag) and holding carnations faces off with a Spanish Civil Guard officer Reuters Catalonia independence referendum: Riot police clash with voters Police try to control the area as people attempt to cast their ballot at a polling station in Barcelona Getty Catalonia independence referendum: Riot police clash with voters A man is grabbed by officers as police move in on the crowds Catalonia independence referendum: Riot police clash with voters Two women argue with a Spanish National policeman during clashes between Catalan pro-independence people and police forces at the Sant Julia de Ramis sports centre in Girona EPA Catalonia independence referendum: Riot police clash with voters Sant Julia De Ramis in Spain Getty Catalonia independence referendum: Riot police clash with voters Confrontation outside a polling station in Barcelona, where police have tried to stop people voting AFP/Getty Images Catalonia independence referendum: Riot police clash with voters A Spanish National Police officer aims a rubber-bullet rifle at pro-referendum supporters in Barcelona AP Catalonia independence referendum: Riot police clash with voters Riot police clashed with voters as polls opened in Barcelona Sky News

The crisis has also caused disquiet among Spain's European Union partners, and German Chancellor Angela Merkel has discussed it with European Commission President Jean-Claude Juncker, an EU official told Reuters.

Concern is growing in EU capitals about the impact of the crisis on the Spanish economy, the fourth largest in the euro zone, and on possible spillovers to other economies.

European finance ministers, gathering in Brussels on Monday and Tuesday for a regular meeting, could discuss the issue, although it is not formally on the agenda, EU officials said.

The support given in public statements by EU leaders to Rajoy is combined with concern expressed in private about how the Spanish government's use of police to prevent Catalans from voting last week in the independence referendum could backfire.