Spanish Prime Minister Mariano Rajoy has declared three days of official mourning after 80 people died in a train crash.

Mr Rajoy visited the scene where the train derailed on the outskirts of the northern city of Santiago de Compostela.

94 people were injured, of whom 35 were in a serious condition, including four children, the deputy head of the regional government said. The official said the death toll could rise further.

Police have taken the driver of the train into custody in hospital.

The Galicia region supreme court said in a statement that the judge investigating the accident had ordered police to put the driver in custody and take a statement from him.

The arrested man, who is under formal investigation, was one of two drivers of the train.

Newspaper accounts cited witnesses as saying one driver, Francisco Jose Garzon, who had helped rescue victims, shouted into a phone: "I've derailed! What do I do?"

El Pais newspaper said one of the drivers told the railway station by radio, "We're only human! We're only human!"

"I hope there are no dead, because this will fall on my conscience," he is reported to have said.

Firefighters had to clamber over the twisted metal to try to get survivors out of the windows of the carriages.

Security camera footage of what appears to be the crash has been posted on the website of the El Pais newspaper.

The footage shows a train entering a sharp bend at high speed then careering off the tracks, smashing into a wall running alongside the rail.

The train operated by state rail company Renfe with 256 people on board derailed on the eve of the ancient city's main festival when thousands of Christian pilgrims travel to the city.

It is reported that people from several different countries are among the injured.

Tánaiste and Minister for Foreign Affairs and Trade, Eamon Gilmore said at this stage there is no indication of any Irish involvement in the tragedy.

Mr Gilmore said: "The Galician region and the city of Santiago is a popular destination for Irish travellers and the Irish Embassy in Madrid has been in contact with the regional authorities since the accident occurred.

“The situation is still developing and it will be some time before all of those involved have been identified.”

The Department of Foreign Affairs in Dublin said it is awaiting details from the Galician authorities, who are preparing a list of all passengers and staff on board the train.

Anyone with concerns can contact the department at 01-4082000

"It was going so quickly ... It seems that on a curve the train started to twist, and the wagons piled up one on top of the other," one passenger told Cadena Ser radio station.

One witness near the scene told the radio station she heard an explosion before seeing the derailed train.

The train was travelling from Madrid to Ferrol on the Galician coast when it derailed, Renfe said in a statement.

Mr Rajoy, who was born in Santiago de Compostela, held an emergency meeting with his ministers last night.

"In the face of a tragedy such as just happened in Santiago de Compostela on the eve of its big day, I can only express my deepest sympathy as a Spaniard and a Galician," Mr Rajoy said in a statement.

Festivities cancelled as city mourns

Santiago de Compostela's tourism board said all the festivities, including the traditional High Mass at the centuries-old cathedral, were cancelled as the city went into mourning.

El Pais cited sources close to the investigation as saying the train was travelling at over twice the speed limit on a sharp curve.

Both Renfe and state-owned Adif, which is in charge of the tracks, have opened an investigation into the cause of the derailment, Renfe said.

An official source said no statement would be made regarding the cause of the Spanish derailment until the black boxes of the train were examined, but said it was most likely an accident.

"We are moving away from the hypothesis of sabotage or attack," he said.

Clinics in the city were overwhelmed with people flocking to give blood, while hotels organised free rooms for relatives. The government sent forensic scientists and hospital staff to the region on special flights.

Firefighters called off a strike to help with the disaster, while hospital staff, many operating on reduced salaries because of spending cuts, worked overtime to tend the injured.

The city's main festival focuses on St James, one of Jesus' 12 disciples whose remains are said to rest in the city and who is patron saint of Galicia.

The apostle's shrine there is the destination of the famous El Camino de Santiago pilgrimage, followed by Christians since the Middle Ages.

The derailment was one of the worst rail accidents in Europe over the past 25 years.

Santiago popular with Irish travellers

Taoiseach Enda Kenny has written to Mr Rajoy expressing his sympathy on behalf of the Irish people to the victims of the train crash.

It is understood Mr Kenny said he was particularly touched by the reaction of the Spanish people, as demonstrated by the many queues of those offering to donate blood in the aftermath of the crash.

A Book of Condolence will open at St Andrew's Church, Westland Row, Dublin.