BARCELONA, Spain — Defying the Spanish authorities, tens of thousands of Catalans turned out to vote on Sunday in a banned independence referendum, clashing with police officers sent from outside the region to shut down polling stations and confiscate ballots.
The police in some places used rubber bullets and truncheons to disperse voters, many of whom had spent the night inside polling stations to ensure that they would remain open.
More than 300 people were injured in the crackdown and scuffling that ensued, according to Catalan officials, and Madrid-based newspapers said 11 police officers were wounded.
Even as Spanish security forces intensified the clampdown, the Catalan authorities maintained that voting was proceeding in almost three-quarters of polling stations.
Carles Puigdemont, the Catalan leader, accused the Spanish government in the capital, Madrid, 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 in his hand 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.
Mr. Puigdemont did not say whether his government would be able to announce a referendum result. It was also unclear how far the police intervention would stretch.
Enric Millo, Madrid’s representative in Catalonia, said that “the rule of law has dismantled the illegal referendum,” while deploring 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 in a televised statement.
The referendum on Sunday was a high-water mark in a long-building standoff between Madrid and Catalonia, the prosperous northeastern region and economic powerhouse of Spain.
Aspirations for an independent state among Catalans, who have a distinct language and culture, have ebbed and flowed for generations. But they intensified over the past several years as Catalans complained that Madrid was unfairly siphoning off their wealth and denying people the right to choose their political destiny.
The Madrid government, with the backing of Spanish courts, has 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 thousands, young and old, was 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.
Officers from Catalonia’s autonomous police force, known as the Mossos, watched voters stream in but made no move to interfere.
Then, shortly after polls opened at 9 a.m., Spanish national forces in riot gear entered several sites, including the high school in northeastern Catalonia where the region’s leader, Mr. Puigdemont, was expected to vote.
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 makeshift conditions, with a disputed census used as the voting list.
They are relying on privately printed ballots, after millions of them were seized recently 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 in any poll station, without using an envelope and whether registered there or not.
Mr. Millo, the Spanish government’s representative, said the last-minute change turned what was already an illegal Catalan referendum into “a joke.”
Mr. Millo said the police were ordered to seize election-related equipment and not people, but news channels showed violent altercations. Carles Soler, 52, said he was hurting as he walked barefoot down Carrer Sardenya in Barcelona, after “a police officer hit me from behind.” He added: “My flips flops didn’t resist either.”
As the tensions mounted on the streets, F.C. Barcelona, the soccer club, was considering postponing a match scheduled to take place in its Camp Nou stadium later on Sunday afternoon.
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.
The government of Catalonia, an autonomous region, passed laws last month to approve the referendum, and Prime Minister Rajoy warned that Spain would use all possible means to stop it.
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.
In March, the region’s former leader was fined 36,500 euros, nearly $39,000, and banned from holding public office for organizing a similar referendum in defiance of a court order in 2014.
But Sunday’s vote has left the Spanish premier in a bind, forced to choose between detaining large crowds of civilians — images that would be immediately beamed worldwide via social media — or allowing the vote to proceed, an acknowledgment that he could not control the region.
One serious vulnerability, for the Spanish government, is that the primary police force in Catalonia is the autonomous Mossos, whose leaders had signaled that they would not use force on voters.
Until Sunday morning, the polling sites had a festival atmosphere, preparing vast pans of paella and offering instruction in yoga and drumming.
In some cities like Berga, people continued to vote as normal, aware that 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 in her polling station. The 58-year-old sales assistant was still pleased to have been among the many people who tried to vote on Sunday.
“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.