Details have begun to emerge of how one Catalan police officer shot dead four of the five attackers who ran people down in the coastal town of Cambrils in the early hours of Friday morning.

The five were shot dead after they drove into pedestrians in what appeared to be the country’s second terrorist attack in 24 hours.

The local police chief Josep Lluis Trapero, who is leading the investigation into the attacks, said on Friday afternoon that one officer had killed all but one of the attackers. He said it was “not easy” for the officer involved despite being a professional.

According to the Barcelona-based paper La Vanguardia, the attackers’ Audi A3 ran down three people before smashing into a police car stationed at a checkpoint.

Spotting the attackers emerging from the car with knives, machetes and axes, the officer raised their rifle and shot four of them dead.

The fifth attacker escaped and stabbed a pedestrian in the face before he was shot by another officer with a submachinegun.

Hours earlier a van ploughed along a road in the busy tourist area of Las Ramblas in Barcelona, killing at least 13 people and injuring more than 100. Spanish police are hunting an 18-year-old man who is suspected of driving the van.

Trapero said four suspects – three Moroccans and one Spaniard – had been arrested in connection with the Barcelona attack.

Police believe the attacks in Las Ramblas and Cambrils are linked to an explosion earlier this week at a house in the small town of Alcanar, 120 miles south of Barcelona, that left one person dead and 16 injured. Trapero said police believed the terrorist cell had been in that house planning at least two attacks.

According to La Vanguardia, the officer who shot the four Cambrils attackers had been due to go on holiday this week. The officer is understood to be receiving psychological support in the aftermath of the incident.