© Oscar Corral/EPASpain train crash: the scene close to Santiago de Compostela where a train travelling from Madrid to Ferrol derailed.
At least 77 people died in Wednesday's train crash in the northern Spanish region of Galicia, a spokeswoman for Galicia's supreme court said.

Four died in hospital, the rest at the site of the accident, the spokeswoman said on Thursday morning, adding that the numbers were still provisional. Judges in Spain are responsible for recording deaths.

The crash occurred as the train approached the north-western Spanish city of Santiago de Compostela at 8.40pm. A further 131 people were reported injured in the accident, the worst in Spain for 40 years. Reports said about 20 were very seriously injured.

The death toll might rise further, a spokeswoman for the office of the central government in Galicia warned. One Briton was among the injured, the Foreign Office confirmed.

Rescue workers battled to free passengers trapped inside the carriages, several of which had overturned. Some caught fire. Bodies covered in blankets lay next to the overturned carriages as smoke billowed from the wreckage. Firemen clambered over the twisted metal trying to get survivors out of the windows.

"The scene is shocking, it's Dante-esque," the head of the Galicia region, Alberto Núñez Feijóo, said in a radio interview.

There were some 247 people on board the train, which was travelling from Madrid to the Galician port of Ferrol. The train jumped the tracks on what officials described as "a difficult curve" on the outskirts of Santiago. At least six carriages were derailed.

"The train started flipping over, over and over, and carriages ended up on top of others," one passenger said.

Another said: "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."

Passenger Ricardo Montesco told Cadena Ser radio station: "A lot of people were squashed on the bottom. We tried to squeeze out of the bottom of the wagons to get out and we realised the train was burning ... I was in the second wagon and there was fire ... I saw corpses."

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

El Pais newspaper cited sources close to the investigation as saying the train was travelling at more than twice the speed limit on a sharp curve. The recommended speed is 80km an hour (50mph), and sources suggest the train was travelling as fast as 180km an hour.

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

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

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

One carriage was thrown five metres from the track and landed on the other side of a retaining wall beside a row of houses. Several carriages were almost completely destroyed.

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

Both drivers of the train were unhurt in the crash. One of them was reportedly seen wandering dazed among the dead saying: "I've derailed, what am I going to do, what am I going to do?" It is still not clear whether the apparent excessive speed was the result of human error or a technical fault.

Spain's national rail company, Renfe, admitted that the service was running five minutes late, fuelling the hypothesis that it was trying to make up time.

The crash happened a day before Santiago's main festival, focused on St James. The apostle's shrine is the destination of the famous El Camino de Santiago pilgrimage, followed by Christians since the middle ages. The traditional fiesta de Santiago was cancelled and the archbishop of Santiago, Julián Barrio, sent his condolences. Mariano Rajoy, the prime minister, who was born in Santiago, was due at the scene on Thursday.

"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," Rajoy said in a statement.

Renfe faced criticism because it failed to issue a press release until three hours after the accident and then only reported it as a derailment without any indication of the seriousness of the accident. On Thursday night investigators were still trying to locate the train's "black box" for clues to what caused the accident.

The derailment happened less than two weeks after six people died when a train came off the tracks and hit the platform at a station in central France.

That accident may have been caused by a loose steel plate at a junction, French train operator SNCF said.