Spanish officers on Monday shot dead an Algerian man who tried to attack them with a knife at a police station while shouting "Allahu akbar", police said.
The man entered a police station in Cornella, near Barcelona, just before 6 am (0400 GMT) "to attack the officers" and was "shot down", Catalonia regional police said on Twitter
"An investigation has been launched following the events that occurred this morning at our police station in Cornella in order to clarify the reasons for the attack," the statement said.
Anti-terrorism police sources said the man, a 29-year-old Algerian who lives in the area, had shouted "Allahu akbar" (God is greatest) as he entered the station.
The central government's representative in Catalonia, Teresa Cunillera, told public radio Monday that "it was very difficult to draw any conclusions" until police had finished their investigation.
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 (yards) from the site of the attack.
The incident occurred days after the first anniversary of a deadly jihadist 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.
The Islamic State group claimed responsibility for the attacks, Spain's worst since the Madrid train bombings in 2004, in which 191 people died and more than 1,800 were injured.
Catalonia, which is home to a significant number of second-generation immigrants, has seen 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.
Mohammed Atta, the pilot who slammed a passenger plane into one of New York's World Trade Center towers on Sept 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.