BARCELONA, Spain — A Madrid judge charged two of four suspects in last week’s attacks in Spain with terrorism offenses on Tuesday, after a day of questioning that seemed to confirm that the group had initially planned a more ambitious strike.

The judge, however, ordered the release of one suspect and ordered the fourth to be detained for 72 hours for further questioning.

The four suspects — the only survivors of a terrorism cell that killed 15 people in and near Barcelona — were transferred overnight to Madrid, where they appeared before Fernando Andreu, the judge from Spain’s national court in charge of the case.

Judge Andreu questioned each one in turn on Tuesday, starting with Mohamed Houli Chemlal, 21, who appeared in court in hospital garb. He had been admitted for treatment after being wounded in an explosion at a house that the terrorism cell had used as a bomb factory. The explosion apparently derailed their initial plans for a bombing in Barcelona.