Catalan police on Monday shot dead an Islamist militant who killed more than a dozen people with a van in Barcelona last week, ending a four-day manhunt for the perpetrator of Spain's deadliest attack in over a decade.

Police said they tracked 22-year-old Younes Abouyaaqoub to a rural area near Barcelona and shot him after he held up what looked like an explosives belt and shouted "Allahu Akbar" (God is greatest). A bomb squad then used a robot to approach his body.

Abouyaaqoub had been on the run since Thursday, after he drove at high speed into throngs of strollers along Barcelona's most famous avenue, Las Ramblas. After fleeing, he hijacked a car and fatally stabbed its driver, according to police.

Islamic State claimed responsibility for the attack, which police believe was planned by a dozen accomplices, including a brother and two first cousins of the Moroccan-born Abouyaaqoub.

"Shortly before 5 p.m., the police shot down Younes Abouyaaqoub, the driver of the van in the attack" in Barcelona, Carles Puigdemont, head of the Catalonia regional government, told a news conference.

Fled through vineyards

After four days on the run, Abouyaaqoub was spotted outside a train station west of Barcelona on Monday afternoon. A second witness told police she was certain she had seen the man whose photo has gone around the world as part of an international manhunt.

Two officers found him hiding in a vineyard near Subirats and asked for his identification, according to the head of the Catalan police. He was shot to death when he opened his shirt to reveal what looked to be explosives, regional police chief Josep Luis Trapero said.

A bomb disposal robot was dispatched to examine the downed suspect before police determined the bomb belt was not real, Trapero said. A bag full of knives was found with his body, police said.

Spain Attacks

A police car blocks the road in front of journalists as police work at the scene, right, near Subirats, 45 kilometres west of Barcelona on Monday. (Manu Fernandez/Associated Press)

A police photo of the body seen by The Associated Press showed his bloodied face, bearing several days' stubble on the chin.

Roser Ventura, whose father owns a vineyard between the towns of Sadurni d'Anoia and Subirats, said she spotted a car crossing their property at high speed and alerted the regional Catalan police.

"The police told us to leave the premises and go home. We heard a helicopter flying around and many police cars coming toward the gas station that is some 600 metres from the property," Ventura said.

Shot near sewage treatment plant

Police tracked him down and shot him on a road near a sewage treatment plant.

The scene unfolded 40 kilometres from the spot, close to the FC Barcelona soccer stadium on the outskirts of the city, where police said Abouyaaqoub seized the hijacked car.

Police said Abouyaaqoub had first fled Las Ramblas on foot amid the chaos of the attack, then commandeered the car, stabbing the driver, 34-year-old Pau Perez, to death before smashing his way through a police checkpoint and ditching the car.

Abouyaaqoub had been the only one of 12 accomplices still at large. His mother, Hannou Ghanimi, had appealed for him to surrender, saying she would rather see him in jail than dead.

Four people have been arrested so far in connection with the attacks: three Moroccans and a citizen of Spain's North African enclave of Melilla. They were being taken to the high court in Madrid, which has jurisdiction over terrorism matters.

Abouyaaqoub lived in Ripoll, a town in the Pyrenees mountains north of Barcelona close to the French border.

Islamic State claims

Islamic State also claimed responsibility for a separate deadly assault, hours after the van attack, in the coastal resort town of Cambrils, south of Barcelona.

In Cambrils, a car rammed into passersby before crashing and its occupants got out but the five assailants were shot dead by police. A Spanish woman died in the attack.

In the roughly seven hours of violence that followed the van's entry into the central promenade of Las Ramblas on Thursday afternoon, attackers killed 15 people: 13 on Las Ramblas, the Cambrils victim and the man in the hijacked car.

Of the 120 injured on Las Ramblas, nine remain in a critical condition in hospital.

It was the deadliest attack in Spain since March 2004, when militants placed bombs on commuter trains in Madrid, killing 191 people. That attack was claimed by al-Qaeda.

Spain Attacts

A person believed to be Younes Abouyaaqoub, the man police say drove the van in Thursday's attack, is seen in security camera footage released by the Spanish newspaper El Pais. (El Pais/Associated Press)

Another two suspected plotters in Barcelona, including an imam thought by police to have helped radicalise his young conspirators, were killed on Wednesday night, hours before the Las Ramblas assault began, in what is believed to have been an accidental explosion.

About 120 butane gas cylinders were found at the scene of the explosion, a house in the town of Alcanar, south of Barcelona. Police believe the pair were preparing a much larger attack with explosives, but the blast prompted their accomplices to adopt a new, less elaborate plan.

International investigation still open

Spanish police said the international investigation was still open and have sought information on a visit the imam, Abdelbaki Es Satty, made to Belgium last year, said Thierry Werts, spokesman for the Belgian federal prosecutor's office.

Hans Bonte, mayor of the Belgian town of Vilvoorde, near Brussels, told VRT television on the weekend the imam had been there looking for work. Belgium has suffered several Islamist attacks and Vilvoorde has been a centre of Islamic radicalism.

The van driver, Abouyaaqoub, began showing more religiously conservative behaviour over the past year, said relatives in his native Morocco. He refused to shake hands with women during a visit to his birthplace in March, they said.

Abouyaaqoub's brother El Houssaine and first cousins Mohamed and Omar Hychami were among those killed by police in Cambrils. They were all originally from the small Moroccan town of Mrirt.

Spain Attacks

Hanna, left, the mother of Younes Abouyaaqoub, and other relatives of young men believed responsible for the attacks in Barcelona and Cambrils, stand with a woman holding a sign reading in Catalan: 'Not in my name.' They gathered on Saturday with members of the local Muslim community to denounce terrorism and show their grief, in Ripoll, north of Barcelona. (Francisco Seco/Associated Press)

With files from The Associated Press