Hundreds of thousands of anti-independence protesters have lined the streets of Barcelona chanting “long live Spain" and “prison for Puigdemont” as Madrid moves to impose direct rule on Catalonia.

Political parties opposing secession from Spain had a small lead in an opinion poll published on Sunday, the first since the dismissed Catalan president Carles Puigdemont declared independence on Friday.

The poll of 1,000 people by Sigma Dos for the anti-independence newspaper El Mundo showed anti-independence parties winning 43.4 per cent support and pro-independence parties 42.5 per cent.

The survey was taken from Monday to Thursday, as the Catalan government was preparing to declare independence.

Polls and recent elections have shown that about half the electorate in the wealthy northeastern region, which is already autonomous, oppose secession from Spain, but a vocal independence movement has brought the current crisis to a head.

The Spanish central government in Madrid invoked Article 155 of the constitution on Friday, which allows it to impose direct rule. It has dissolved the Catalan parliament and announced fresh regional elections to be held in December.

The crisis began on 1 October when the Catalan government staged a referendum on independence – which Madrid said was illegal – and announced it would secede from Spain within 48 hours if the people voted yes.

The Civil Guard, Spain’s semi-militarised central police force, were drafted in from Madrid to stop people going to the polls and were widely criticised for their heavy-handed approach which saw them beating voters and firing rubber bullets into the crowd.

Catalan pro-unity demonstration – in pictures Show all 6 1 /6 Catalan pro-unity demonstration – in pictures Catalan pro-unity demonstration – in pictures Pro-unity supporters take part in a demonstration in central Barcelona. Hundreds of thousands of Catalans took to the streets of Barcelona on Sunday to call for their region to remain part of Spain, two days after regional lawmakers exacerbated a political crisis by voting for the wealthy region to secede Reuters/Jon Nazca Catalan pro-unity demonstration – in pictures A woman with the Senera and Spanish flags painted on her face shouts slogans as she takes part in a rally against Catalonia's declaration of independence, in Barcelona AP Photo/Gonzalo Arroyo Catalan pro-unity demonstration – in pictures Thousands of pro-unity protesters gather in Barcelona, two days after the Catalan parliament voted to split from Spain Jeff J Mitchell/Gett Catalan pro-unity demonstration – in pictures People support a pro-unity demonstration from their balconies in central Barcelona Reuters/Rafael Marchante Catalan pro-unity demonstration – in pictures Pro-unity supporters take part in a demonstration in central Barcelona Reuters/Yves Herman Catalan pro-unity demonstration – in pictures Protesters wave Spanish flags and carry banners during a pro-unity demonstration on in Barcelona Jack Taylor/Getty

The final result saw 90 per cent of people opting for independence on a turnout of 43 per cent, which the Catalan government said gave them a mandate for independence, but critics said unionists mostly boycotted the vote.

Waving thousands of Spanish flags and singing “Viva Espana”, protesters turned out on Sunday in the largest display of support for a united Spain since the beginning of the crisis – underlining the depth of division in Catalonia itself.

Organisers put attendance at 1.3 million people, while the police reported that the protest had drawn 300,000 participants.

“I'm here to defend Spanish unity and the law,” said Alfonso Machado, 55, a salesman standing with a little girl with Spanish flags in her hair.

“Knowing that in the end there won't be independence, I feel sorry for all the people tricked into thinking there could be and the divisions they've driven through Catalan society.”

European countries, the US and Mexico have also refused to recognise the Catalan declaration of independence and expressed support for Spain's unity.

But emotions are running high and the next few days will be tricky for Madrid as it embarks on enforcing direct rule and putting officials in administrative roles.

Officers of the regional police force, the Mossos d'Esquadra, were stationed in main public and government buildings on Sunday.

But the force is believed to have divided loyalties. The central government has removed the Mossos' chief, Josep Lluis Trapero, and said units could be replaced if warranted.

The main secessionist group, the Catalan National Assembly, has urged civil servants not to follow orders from the central government and to mount “peaceful resistance”, while the pro-independence trade union CSC has called a strike.