The cell behind the Barcelona van attack had planned to use explosives against monuments including the Sagrada Familia church, a suspect has told a Madrid court.
Mohamed Houli Chemlal is one of four surviving suspects who gave evidence.
The group's plans were scaled back when a house packed with bomb-making equipment blew up the day before.
Houli Chemlal was injured in the accidental blast that reduced the house to rubble in the town of Alcanar.
The Alcanar explosion came the day before Thursday's Barcelona attack in which a van was driven at speed down the main Las Ramblas boulevard, killing 13 and injuring more than 100.
Judicial sources quoted Houli Chemlal as telling the court a much bigger series of attacks had been planned.
Assailants killed a total of 15 people in the van attack, the stabbing of a driver whose car was commandeered shortly afterwards, and a car attack in the resort of Cambrils hours later.
Eight alleged members of the cell are dead - two were killed in the Alcanar explosion, and six were later shot by police, including five after the Cambrils attack.
The last suspect to be killed was Moroccan-born Younes Abouyaaqoub, 22, believed to be the driver of the Las Ramblas van.
Wearing a fake explosives belt and armed with knives, he was shot dead by police in a vineyard west of Barcelona on Monday.
The surviving suspects were moved, under high security, from Barcelona to Madrid for Tuesday's hearing.
The court session, a preliminary hearing to gather evidence for a future trial, took place behind closed doors.
The four suspects have been charged in court with terrorist murder, belonging to a terrorist organisation and possession of explosives, according to a source.
Houli Chemlal was the first to testify, wearing hospital pyjamas. He is still being treated for his injuries from the blast in Alcanar.
Driss Oukabir, whose brother Moussa was among suspects killed after the Cambrils attack, has also given evidence to the Madrid court.
According to judicial sources, he has changed his story to say that he admits renting the van used in the Las Ramblas attack but thought it was to be used for a house-move.
Under earlier police interrogation, he is said to have maintained that his brother Moussa hired the van using documents stolen from him.
Two other suspects were killed in the Alcanar explosion, including Abdelbaki Es Satty, the Moroccan imam from the town of Ripoll thought to have been a radicalising influence on the suspects.
The two other suspects appearing in court were Mohammed Aallaa, 27, alleged owner of the Audi car used in the Cambrils attack; and Salah al-Karib, 34, accused of running an internet cafe in Ripoll used to send money to Morocco.
All four suspects giving evidence are reported to have testified that Es Satty was the ringleader of the group.
As Tuesday's Madrid hearing took place, Ana Suárez, a Spanish woman in her 60s killed in Cambrils, was buried in a private ceremony in Zaragoza.
Forty-five companies in a Catalonia association of undertakers and funeral companies have offered to perform funerals for the victims without charge.
Meanwhile, French Interior Minister Gerard Collomb has confirmed previous reports that some of the attackers made an overnight visit to France days before.
He told BFMTV it had been an "extremely fast return trip" to the Essonne area of Paris on 11-12 August, during which their Audi A3 had been caught on speed cameras.
But he insisted the cell had no French links - "they were exclusively Spanish".
Most of the 12 suspects lived in Ripoll, north of Barcelona close to the French border. All were young men of North African descent.
- BBC