Barcelona: A police officer shot dead a man armed with a knife as he tried to attack a police station in Catalonia on Monday, just days after the one-year anniversary of a twin attack in the northern Spanish region that killed 16 people.
"We are treating it as a terrorist attack. The officer used her gun to save her own life," Rafel Comes, a commissioner with the Catalan regional police, told a news conference in Cornella de Llobregat where the attack took place.
The man arrived at the police station in the town near Barcelona at 5.45am (0345 GMT) with a knife and "a clearly premeditated desire to kill an agent of our force", he added, saying security was being reinforced at police stations across Catalonia.
Anti-terrorism police sources had earlier told AFP that the man was a 29-year-old Algerian who lived in the area, and had shouted "Allahu akbar" (God is greatest) as he entered the station.
VIDEO: The body of a man who attempted to launch a knife attack on a police station near Barcelona is removed from the building. Catalonia regional police confirmed that they had shot the armed man after he entered the station #Cornella pic.twitter.com/do1wn2fOlL— AFP news agency (@AFP) August 20, 2018
But Comes said the agent who shot the man dead can only recall hearing him invoking the name of "Allah" and the rest of what he said was incomprehensible.
The commissioner would not confirm the attacker was Algerian, saying police still needed to confirm that the Algerian identity papers he carried with him were in fact his.
The police station was cordoned off and funeral home employees removed the attacker's body from the building, an AFP photographer at the scene said.
Officers searched the man's home, which was located just a few hundred metres from the site of the attack.
The incident occurred just days after the first anniversary of a deadly rampage in Catalonia.
Sixteen people were killed on August 17, 2017, when a van drove into crowds on Barcelona's popular Las Ramblas boulevard and in a knife attack in the nearby resort of Cambrils.
Daesh claimed responsibility for the attacks, Spain's worst since the Madrid train bombings in 2004 when 191 people died and more than 1,800 were injured.
Daesh targets police
Spain has kept its terrorist alert at the second-highest level since 2015.
Catalonia, which is home to a significant number of second-generation North African immigrants, has had a long history of Islamic militant activity.
Spain's first Muslim extremist - a member of the Algerian Armed Islamic Group (GIA) - was uncovered in Catalonia in 1995.
Mohammad Atta, the pilot who slammed a passenger plane into one of New York's World Trade Center towers on September 11, 2001, spent time in Catalonia shortly before the attacks.
And in 2008, a plot targeting Barcelona's underground trains was foiled when it was already in advanced stages.
One in four people detained in Spain in relation to extremist Muslim-linked terrorism come from the Catalan province of Barcelona, according to a study published last year by the Real Instituto Elcano, a Spanish think-tank, which called the province the country's "main centre of jihadist activity".
There have been a string of similar incidents in neighbouring France targeting police and soldiers, including one in January 2016 in which police shot dead a man wielding a cleaver and yelling "Allahu akbar" as he tried to attack a police station in northern Paris.
That incident came on the one-year anniversary of the terrorist attack on satirical newspaper Charlie Hebdo.
Daesh has frequently called on their followers to attack soldiers and police in France, who they see as a legitimate target because they represent the French state.