"We will not back down in the face of terrorist killings. The perpetrators will be tried and convicted," he said.
"We are targeting the total, complete and unconditional defeat of terrorism," said Aznar, who offered his condolences to the families of the victims.
"I share their terrible loss. The government is with them. We will never forget what has happened," said Aznar at a sombre televised address, six hours after a wave of bombings on four packed commuter trains on Thursday.
Aznar confirmed Spain would hold three days official mourning for the victims of the attacks, which his government blamed on the armed Basque separatist group ETA.
"Terrorism is not blind. These terrorists wanted to cause as much damage as possible. It is a massacre. They have killed many people simply for being Spanish," said Aznar.
"They have killed many people simply for being Spanish"
Jose Maria Aznar,
prime minister, Spain
"There can be no negotiation with these murderers. We will only stop these attacks by taking a hard line," he said.
"We will not deviate from that line, whether they kill or cease to kill," said Aznar, who himself escaped an ETA attempt on his life in 1995, just months before he became prime minister.
"We are with the victims, we are on the side of the constitution, guaranteeing the rights of all in a united and plural Spain," Aznar said after a crisis meeting of his cabinet.
The Spanish leader also paid generous tribute to the rescuers and to passersby who had offered help.