Madrid: Tens of thousands of Catalan separatists took to the streets in Barcelona in a final rally ahead of Sunday's planned referendum on independence from Spain.

Seven and a half million people in Catalonia will head to the polls in a vote which has been condemned as illegal by Madrid. Regional President Carles Puigdemont told the crowd during the rally on Friday that he believed Catalonia would be taking its first steps as a sovereign nation, BBC reported.

"Friends, so that victory is definite, on Sunday let's dress up in referendum (clothes) and leave home prepared to change history," Puigdemont said.

Catalonia, a wealthy region in north-eastern Spain, has its own language and culture and a high degree of autonomy, but is not recognised as a separate nation under the Spanish constitution.

The Madrid-based Spanish government has maintained the ballot cannot and will not happen because it contravenes the constitution, which refers to "the indissoluble unity of the Spanish nation".

Police across Catalonia were ordered to prevent public buildings being used as polling stations on Sunday. Masses of referendum materials were confiscated by police in recent weeks and officials involved in running the campaign face prosecution.

However, the Catalan regional government and local civic groups say they are entitled to exercise their democratic rights and plan to open more than 2,000 polling stations regardless of the obstacles.

Despite the tension in the region, demonstrations by independence campaigners had been largely peaceful.

"I don't believe there will be anyone who will use violence or who will want to provoke violence that will tarnish the irreproachable image of the Catalan independence movement as pacifist," the Catalonia Regional President said.