A Mass has been held in north-western Spain for the 79 people who died in a train crash.
The service was held in the Galician city of Santiago de Compostela, a Catholic pilgrimage site where the train derailed last week.
Prime Minister Mariano Rajoy, who comes from the city, and members of the royal family attended.
Train driver Francisco Jose Garzon Amo, who faces charges of reckless homicide, was released from custody on Sunday.
Santiago officials had been preparing for the religious feast of St James of Compostela - Spain's patron saint - but cancelled it after the crash on Wednesday.
The heir to the Spanish crown, Prince Felipe, and his wife Princess Letizia joined the grieving families and local residents in the cathedral as the city's archbishop prayed for the dead.
"Families who have lost your loved ones, from the first moment we have had you in our hearts, as have Galicia and Spain, and so many people beyond our borders who have asked me to pass on their condolences," Archbishop Julian Barrio told the congregation.
Mr Rajoy sat with government ministers and regional officials as a choir sang solemn hymns.
After the service, the royal family - dressed in black - kissed and clasped the hands of grieving family members sitting in the front pews.
Locals paying their respects outside the cathedral watched the ceremony on a large screen, as pilgrims left flowers and candles to commemorate victims of the crash.
Officials say 70 people remain in hospital, 22 of them in a critical condition.
Mr Garzon, 52, arrived at court in handcuffs on Sunday, his head scarred by an injury he suffered in the crash.
He was questioned behind closed doors for almost two hours by Judge Luis Alaez.
Later, a court statement said he had been released pending further investigations but must appear before a court once a week and was not allowed to leave Spain without permission.
His passport has been surrendered to the judge and his licence to drive a train has been suspended.
Under Spanish law, his legal status is that he is suspected of being involved in 79 counts of reckless homicide but has not been formally charged.
But officials said he had admitted negligence by being careless when rounding a bend too fast.
Reports have suggested the train was going at 190km/h (118mph) as he took the bend, where the speed limit is just 80km/h.
All eight carriages of the train careered off the tracks into a concrete wall as they sped around the curve on the express route between Madrid and the port city of Ferrol on the Galician coast.
The crash was one of the worst rail disasters in Spanish history.