A Moroccan man was arrested in Barcelona for praising the beheading of a French schoolteacher outside Paris this month and inciting more attacks, police said on Saturday.
The man, who was not named and who was detained on Friday, posted messages on social media in support of the October 16 murder of Samuel Paty, Catalan regional police said.
Paty was killed outside his school in a Paris suburb by an 18-year-old Chechen who was apparently incensed by the teacher showing a cartoon of the Prophet Mohammad in class. Police shot the attacker dead.
"Police officers from the Mossos d'Esquadra have arrested a man of Moroccan nationality, for an alleged crime of exaltation of terrorism and a crime of incitement to commit terrorist crimes," Catalan police tweeted.
The suspect appeared before a court in Barcelona on Saturday and was released on condition he surrender his passport and appear before magistrates every 14 days, police said.
An attacker killed three people in a church in Nice on Thursday in the second deadly knife attack in France in two weeks. Three people have been taken into custody.
The attacks came amid growing Muslim anger across the world over France's defence of the right to publish cartoons depicting the prophet.
French President Emmanuel Macron has deployed thousands of soldiers to protect sites such as places of worship and schools, and ministers have warned that other Islamist militant attacks could take place.
Police will guard French schools in the Spanish region of Catalonia from next week.