BARCELONA, Spain — Catalonia’s defiant attempt to stage an independence referendum descended into chaos on Sunday, as voters clashed with the Spanish national police in one of the most serious tests of the country’s democracy since the end of the Franco dictatorship in the 1970s.
After the Catalan police allowed voting to commence, national police dressed in riot gear deployed in large numbers as they fanned out across the restive northeastern region to close polling stations and seize ballot boxes.
Over the course of the day, the referendum took on an almost surreal cast. The voting went ahead in many towns and cities, with men and women, young and old, singing, clapping and chanting as they lined up for hours to cast ballots, even as confrontations with the police turned violent elsewhere.
The police, sent by the central government in Madrid from other parts of Spain, used rubber bullets and truncheons in some places. The clashes quickly spoiled what had been a festive, if expectant, atmosphere through the night and into the early morning among voters, many of whom had camped out inside polling stations to ensure that they would remain open.
More than 460 people were injured in the crackdown and scuffling that ensued, according to Catalan officials, while a dozen Spanish police officers were wounded, according to Spain’s interior ministry.
The confrontations dangerously intensified the struggle over the status of Catalonia, where aspirations for independence in a prosperous region with a distinct language and culture have ebbed and flowed for generations.
The referendum on Sunday was a high-water mark in a long-building standoff between the national government and Catalonia, Spain’s economic powerhouse. Catalans have long complained that Madrid was unfairly siphoning off their wealth and denying people the right to choose their political destiny.
Though it was far from clear that Sunday’s vote would produce a reliable result, both sides quickly claimed victory — and victimization.
Spanish authorities accused the separatist government of irresponsibly encouraging voters to violate Spanish law and declared that the referendum had been successfully disrupted. The Catalan authorities maintained that balloting had proceeded in almost three-quarters of polling stations.
Carles Puigdemont, the Catalan leader, accused the Spanish government of using “unjustified and irresponsible” means to stop Catalonia’s voters, “with truncheons against ballot boxes.”
“The image of the Spanish state has reached levels of shame that will stay with them forever,” Mr. Puigdemont said, holding a red carnation as he addressed a crowd in the town of Sant Julià de Ramis.
“Today, the Spanish state has lost a lot more than it had already lost, and Catalan citizens have won a lot more than they had won until now,” he said.
Soraya Sáenz de Santamaría, Spain’s deputy prime minister, later praised the Spanish police for blocking a vote that “couldn’t be celebrated and wasn’t celebrated.” She told a news conference that the Catalan government had acted “with absolute irresponsibility, which had to be overcome by the professionalism of the security forces.”
The Madrid government, with the backing of Spanish courts, declared the referendum unconstitutional and ordered the vote suspended. But that did not stop Catalans from lining up before sunrise on Sunday, massing on rain-slicked streets in towns and cities across the region.
The turnout by thousandswas an extraordinary show of determination in the face of a steady drumbeat of threats from the government in Madrid, which had ordered the police to seal public facilities to prevent voting.
Ada Colau, the left-wing mayor of Barcelona, called on Prime Minister Mariano Rajoy to resign over his “cowardly” and unjustified police intervention.
“Today, we’re not talking about independence or not, but about a breakup between Mariano Rajoy and his government with Catalonia,” she told reporters.
Overnight, Catalans had used tractors to block police access to some rural municipalities so that the vote could go on. In other places, residents removed the doors of polling stations to ensure that the police could not bolt them on Sunday.
Catalans are voting not only without backing from Madrid, but also without any sign of support from the European Union or other major players in the international community. The vote is happening in improvised conditions, with a disputed census used as the voting list.
They are relying on privately printed ballots, after millions of them were seized by the police. To prevent a shutdown, the Catalan government changed the voting rules an hour before poll stations were scheduled to open on Sunday, allowing Catalans to cast a ballot at any poll station, without using an envelope and whether registered there or not.
Enric Millo, the Spanish government’s representative in Catalonia, said the last-minute change turned what was already an illegal referendum into “a joke.”
Mr. Millo deplored the fact the national police were forced to take over from Catalan police officers who failed to stop the voting. “We’re being forced to do what we didn’t want to do,” he said.
On Sunday afternoon, F.C. Barcelona, the soccer club, played a match behind closed doors in its Camp Nou stadium. The seats were empty. As the tensions and confusion mounted, Catalan police also intervened in Barcelona’s main downtown square to prevent clashes between separatists and a small group of far-right partisans of Spain.
A few outsiders had traveled to Catalonia from other countries to act as observers, saying they wanted to make sure that the police did not use force against voters.
Dimitrij Rupel, a former foreign minister of Slovenia, led a delegation of 35 foreign officials invited by the Catalan government. After watching the police intervene, he said that the “police have nothing to do with the democratic process — they shouldn’t be here.”
Others compared the situation in Catalonia with that in their own independence-minded regions, precisely what has concerned European Union officials and neighboring governments.
“Every person in the world should have the right to decide their present and future, which of course means the right to vote,” said Andrea Favaro, an Italian lawyer, who waited inside a polling station early on Sunday. Mr. Favoro is from the Veneto region that has held a nonbinding ballot on independence from Italy.
Recent opinion polls suggest that slightly less than half of Catalonia’s 7.5 million people support separation from Spain, but separatist parties won a majority in the region’s Parliament in 2015 and their influence has grown.
Many say Catalonia would face a perilous and uncertain future outside Spain, the market for most of the region’s goods, and would not be assured of being readmitted to the European Union.
Others complained that the thrust for independence had deepened divisions within the region, whose vibrant economy has attracted families from inside and outside Spain.
Olga Noheda, a doctor in Centelles, said one of her patients, an older man, began crying in her examination room, and explained that his granddaughter had begun expressing dislike for Spaniards.
“He was very sad, because he didn’t understand where it all came from,” she said. “He migrated to Catalonia many years ago, from Seville, and he was wondering if his granddaughter was aware that he was a Spaniard.”
In the days leading up to the vote, school principals had received letters threatening them with sedition charges, which carry a 15-year prison term, if they willingly allowed their buildings to be used as polling stations.
City officials were told they would face criminal charges for misusing public funds. In one city, the local newspaper editor discovered he faced a criminal complaint after he printed a list of schools that would be holding votes.
Ten days ago, Spanish police detained a dozen officials of Catalan’s regional government, including its secretary general of economic affairs.
Still, in some Catalan cities like Berga, people lined up to vote early, aware that the Spanish police could intervene later in the day. A car toured the city with a megaphone, calling on citizens to go to their polling stations “to defend the ballot boxes and democracy.”
In the southern port city of Tarragona, Emilia Roldan Cano was the first and last person to cast a vote before police confiscated the ballot box at her polling station. The 58-year-old sales assistant was still pleased to have been among the many people who cast a ballot.
“I am Catalan and I love Catalonia,” said Ms. Roldan Cano, whose parents moved to the region from Andalusia in the 1950s, looking for work. “And now I like it more, seeing all that I see.”
Ellen Barry and Raphael Minder reported from Barcelona, and Palko Karasz from Tarragona, Spain. Silvia Taulés and Marta Arias contributed reporting from Barcelona, and Germán Aranda from Berga, Spain.