In scenes that reverberated around Spain, riot police smashed their way into some polling locations and beat back voters with batons as they attempted to take part in the referendum. Regional officials said more than 800 people were injured.

The mood on the streets of the regional capital, Barcelona, was tense as polls closed Sunday night. Crowds of people waving the regional flag and banners that read "Si" gathered in Plaza Catalonia to await results, which are expected to be announced Sunday night.

Shortly after voting ended, Spain's Prime Minister said there was no referendum and that most Catalans were fooled into participating in an illegal vote. Spain's top court declared the referendum illegal.

"At this point, I can tell you very clearly: Today a self-determination referendum in Catalonia didn't happen. We proved today that our state reacts with all its legal means against every provocation," Prime Minister Mariano Rajoy said in a televised speech.

Read More

But Catalan President Carles Puigdemont remained defiant Sunday night as he condemned the violence, calling it a "shameful page" in the country's history.

-- The Spanish Deputy Prime Minister blamed the violence on the determination of the Catalan authorities to go ahead with the vote, despite it being declared illegal.

-- Pictures showed people with injuries sustained in clashes with police.

People help a man injured by a rubber bullet fired by Spanish police officers outside the Ramon Llull polling station in Barcelona.

Spain: referendum is 'blatantly illegal'

The national government is implacably opposed to any breakaway moves by the northeastern region. Spanish Deputy Prime Minister Soraya Sáenz de Santamaría blamed the violence on the "crazy rush" of the Catalan regional government to hold the "unconstitutional" vote.

"The referendum couldn't be held, and it's not been held. To carry on with this farce makes no sense, it doesn't lead anywhere," she said in a news conference in Madrid on Sunday.

"The [Spanish] government always maintained that the referendum would not take place," he said. "[The Catalan government] knew the referendum was illegal and impossible, but they decided to carry forward with their attack to the democratic state."

Catalan government condemns 'state violence'

In Girona, where Puigdemont was due to vote, police smashed their way into a polling station by breaking a glass window. Puigdemont cast his ballot in a nearby village. Catalan authorities said Education Minister Clara Ponsati i Obiols was forcibly removed from her polling station.

JUST WATCHED

High tensions surround Catalonia referendum

MUST WATCH

High tensions surround Catalonia referendum02:13

Two hours after polling began, regional government spokesperson Jordi Turull said 73% of polling stations were open despite the Spanish government's efforts. He challenged the Spanish government's claim that police force was only used to confiscate electoral material, citing the number of people injured and adding that "rubber bullets and tear gas is not how you seize material."

He accused Madrid of being responsible for "a state violence unknown to Spain since the age of Franco," referring to the former military dictator Francisco Franco who ruled the country with an iron fist for 36 years until 1975.

Baton-wielding Spanish National Police clash with pro-referendum supporters in Barcelona.

"The violation of fundamental rights in Catalonia is not an internal problem of Spain, it is an internal problem of the EU, and we Catalans are citizens of the EU," Turull said. When asked by a reporter if the unrest was worth it, he replied, "Defending democracy will be always worth it."

In a tweet, the Catalan administration called on the Spanish government representative in the province to resign.

"Considering his remarks, we can only urge him to step down immediately for being directly responsible for the repression seen today"

Voters defy Madrid to cast ballots

People wait at the doors of a school in Barcelona to start voting during the Catalan independence referendum.

Throughout the region, a combination of excitement and tension prevailed as people cast their votes. Elderly people were applauded as they emerged from polling stations, while others hugged friends.

"This moment means a lot to me," Joana Rauet, 89, told CNN after voting at the Josep Maria Jojol school in Barcelona on Sunday. "I feel satisfied that I was able to take part. I'm feeling very happy," she said.

People told CNN they were told to stay in case the police arrived to shut the voting station down.

"If the police show up, I will stand my ground. I will peacefully resist," Xan Fernando, 20, a student told CNN.

A group of firefighters, including Miguel Ruiz, right, vowed to protect the vote.

Supporters of the referendum were unsure whether police would attempt to prevent ballot papers from being counted. At the largest polling station in Barcelona, a group of firefighters in uniform joined crowds gathered at the Institut Escola del Treball school to prevent police from seizing the ballots.

"We're here to show support, to help if necessary and also to put ourselves in front if it comes to that," said Miguel Ruiz, 44.

Why is the referendum taking place?

Catalonia, a wealthy region in Spain's northeast, has its own regional government -- or Generalitat -- which already has considerable powers over health care, education and tax collection.

But Catalan nationalists want more, arguing that they are a separate nation with their own history, culture and language and that they should have increased fiscal independence.

The region pays tax to Madrid. Pro-independence politicians argue that complex mechanisms for redistributing tax revenue are unfair on wealthier areas and result in Catalonian revenues subsidizing other parts of Spain.

Others, including the Prime Minister, insist that the country cannot be divided. On Sunday night, Rajoy blamed the referendum for dividing the country and creating violence.

"The referendum that wanted to liquidate our constitution and separate a part of our country with no regards to the opinion of the whole nation did not came into existence," he said. "We showed that our democratic state has the means to protect itself from such a serious attack as the one this illegal referendum represented."

Catalonia's campaign to break away has been gaining momentum since 2010, when Spain's economy plunged during the financial crisis. Catalonia held a symbolic poll in 2014, in which 80% of voters backed complete secession -- but only 32% of the electorate turned out.

People wave Spanish flags as thousands demonstrate Saturday in Madrid in favor of national unity.

In the runup to the vote, national authorities seized ballot papers, voter lists and campaign material. Thousands of extra national police were sent to the region. High-ranking Catalan officials involved in organizing the referendum were arrested.