"Obviously I condemn the attacks unconditionally and completely. That is my very clear and absolute conviction," said Ahmed, who is appealing an Italian court ruling that convicted him of belonging to a terrorist organisation last year.
"Thanks to God I am a Muslim but I practice my religion in a normal way, not an extremist way," said Ahmed, dressed in jeans and a white jacket and speaking through a translator.
The Spanish state prosecutor has charged Ahmed with inciting people to carry out the Madrid bombings - which he denies - and asked for him to be sentenced to more than 38,000 years in jail. The maximum anybody can serve in Spain is 40 years.
Seven lead defendants face possible jail terms of 30 years for each of the killings and 18 years apiece for 1,820 attempted murders in what prosecutors say was an al-Qaeda-inspired attack.
|"Obviously I condemn the attacks unconditionally and completely. That is my very clear and absolute conviction"|
Rabei Osman Sayed Ahmed
Ahmed, who earlier refused to answer questions from prosecutors, is one of four men the state attorney says heeded a call by al-Qaeda leader Osama bin Laden in 2003 for people to attack countries that backed the US-led war in Iraq.
All the defendants have pleaded not guilty.
Other suspects include Moroccans Jamal Zougam and Abdelmajid Bouchar, both accused of planting bombs.
Spaniard Emilio Trashorras, a former miner, is accused of supplying dynamite, and Youssef Belhadj is suspected of making key decisions about the attack, such as the date and of giving last-minute instructions.
The attack, in which 10 backpack bombs exploded and ripped through four packed commuter trains, has been called Spain's most traumatic event since the 1930s civil war.
Security was extremely tight for the trial, with police on horseback patrolling outside the court on the city's outskirts, and bomb-sniffing dogs searching for explosives.
Testimony was expected to last for more than five months, and a verdict is expected in late October.
The trial marks the culmination of a lengthy investigation, which concluded that the attack was carried out by a homegrown cell of extremists angry over the then-conservative Spanish government's support for the Iraq war and its troop presence in Afghanistan.
The group was inspired by al-Qaeda, but had no direct links to it, nor did it receive financing from Osama bin Laden's organisation, Spanish investigators say.
That government initially blamed Basque separatists, and continued to do so even as evidence emerged to the contrary. This led to charges of a cover up, and in elections three days after the attack Socialists were voted into power. They quickly brought Spain's troops home from Iraq.
Spain has since raised its three-stage alert level to the middle rung as a precautionary measure.