Spanish police have killed several people in a coastal town south of Barcelona in response to a terrorist attack.

Reports of an operation by security services in Cambrils emerged shortly after 1am local time, some eight hours after a van driver killed 13 people and injured more than 100 in a terrorist attack in Barcelona.

Bystanders could be seen running for cover and several gunshots heard in footage posted on social media that appeared to have been filmed on the town's beachfront promenade.

Two people were arrested after the earlier incident, when a white Fiat van tore through the Las Ramblas district, which was packed with shoppers and holidaymakers.

Police confirmed neither of those in custody was the driver behind the atrocity, which Spain's prime minister Mariano Rajoy described as "jihad terrorism".

Mossos, the Catalan police force, urged locals to take cover tweeting: "Police operation in #Cambrils for possible terrorist attack. If you are now in #Cambrils avoid going out. Stay home, stay safe."

According to Spanish broadcaster RTVE police opened fire killing four people and injuring one other.

The broadcaster said police had suspected they were planning an attack in the wake of the deadly rampage in Las Ramblas.

In another clip posted on social media at least three bodies could be seen lying on the floor.