A man wielding a machete stormed two churches in southern Spain late on Wednesday, killing a church official and seriously injuring a priest, the government said.
The attack took place in the port city of Algeciras in Spain's southern Andalusia region, with prosecutors immediately opening a terrorism investigation.
"Just after 7pm this evening, a man entered the church of San Isidro in Algeciras where, armed with a machete, he attacked the priest, leaving him seriously wounded," the Interior Ministry said.
"Subsequently, he entered the church of Nuestra Senora de La Palma in which, after causing damages, he attacked the verger.
"The verger managed to get out of the church but was caught by the attacker outside and sustained mortal injuries."
The Ministry said he had died on the spot.
"Moments later, [the assailant] was disarmed and arrested and is currently in police custody," it said.
The two churches are several hundred metres apart in an area very close to the port.
Police initially said several people had been wounded but later clarified it was only the priest, with the emergency services confirming he had sustained injuries "to the neck".
The Mayor of Algeciras said the verger who died was Diego Valencia. He identified the priest as Antonio Rodriguez.
In a post on Twitter, the local congregation said Rodriguez, 74, had been celebrating the Eucharist at San Isidro church when he was attacked. They described his condition as "serious but stable".
A police source told AFP the assailant was wearing a long robe and had "shouted something" as he carried out the attack.
Witnesses at Nuestra Senora de La Palma told local media that a man ran into the building about 7.30pm, just as they were finishing the Eucharist service.
They said he was shouting and had started to throw icons, crosses and candles to the floor.
Prosecutors opened an investigation that is being led by a judge from the Audiencia Nacional, Spain's top criminal court, which handles terrorism-related cases.
Police did not identify the suspect but released a video in which he is seen from behind wearing a black, white and grey hoodie and black trousers, and being led away handcuffed by two police officers.
Algeciras town hall said it would hold an official day of mourning on Thursday when flags would be lowered to half-mast. A demonstration would take place at midday to express outrage at the bloodshed.
The attack drew swift condemnation from across the political spectrum.
"I send my deepest condolences to the families of the verger who die in this terrible attack," Prime Minister Pedro Sanchez wrote on Twitter, wishing a quick recovery to the injured priest.
Opposition leader Alberto Nunez Feijoo of the right-wing Popular Party said he was "appalled" by the incident.
Police have not commented on the possible motives, or political and religious affiliation of the attacker.
But the incident was denounced by the local Muslim community, which said it condemned "the brutal and vicious attack in Algeciras" and deplored the verger's death.
"These criminal acts, which some want to link to Islam or Muslims, tarnish the coexistence that society in Algeciras has historically enjoyed," it said on the Facebook account of Ishbilia mosque in Seville, the regional capital.
"These reprehensible acts are far from our religion and the Muslim community."