Catalonia regional police officers on Monday shot dead an Algerian man who entered a police station in Cornella, near Barcelona.
Abdelouahab Taib entered the station just before 6 am "to attack the officers" and was "shot down", police said on Twitter.
Anti-terrorism police sources said the man, a 29-year-old Algerian who lives in the area, had shouted "Allahu akbar" as he entered the station.
Officers searched the man's home, which was located just a few hundred meters from the site of the attack.
Taib had been living in Spain for several years and had a foreigners' identity number. Police sources confirmed his neighbor’s accounts that he had begun divorce proceedings.
They also said he had no criminal record.
According to the neighbors, Taib had moved to the neighborhood around two years ago after having a relationship with a Spanish woman, who later converted to Islam.
The woman had two children from her former husband, an Asian, who also lived in the same apartment, the neighbors said.
Witnesses said that police took the woman for investigation while her children were away on summer vacation with their father.
Commissioner Rafel Comes, the second-in-command of the Catalan regional police, told reporters that police are treating the case as a terrorist attack "for the moment" because the incident was "extremely serious," involving a "premeditated" attack that intended to kill police.