At least 21 people have been killed and several injured after two trains collided in southern Spain on Sunday night, authorities said.

A train travelling from Málaga to Madrid derailed near Adamuz, crossing on to the other track where it hit an oncoming train, which also derailed, Spain’s Adif rail body posted on X.

“The [Madrid] to Huelva train, which was travelling on the adjacent track, has also derailed,” it added.

Adif said the accident happened about 10 minutes after the Iryo train left Málaga heading towards Madrid at 6.40pm (17.40 GMT).

“We have received calls from people reporting that there were injured and trapped,” a spokesperson for the Andalusian emergency services told AFP.

The Spanish interior ministry said 21 people were dead.

Reports from the country’s state-owned broadcaster said that 100 people had been injured, 25 seriously.

One witness told the public broadcaster RTVE that one of the carriages of the first train had completely overturned.

Television images showed medical crews and fire services at the scene.

A journalist from the public broadcaster RNE who was travelling on one of the trains said the impact had felt like “an earthquake”.

Passengers had used emergency hammers to break carriages windows and get out, he said.

Some of the train carriages after the crash. Photograph: Eleanorinthesky On Social Media X Handout/EPA

A woman named Carmen posted on X that she had been on board the Iryo to Madrid train. “Ten minutes after departing (from Córdoba) the train started to shake a lot, and it derailed from coach 6 behind us. The lights went out.”

Footage posted by another Iryo train passenger, also on X, showed an Iryo staffer in a fluorescent jacket instructing passengers to remain in their seats in the darkened carriages, and those with first aid training to keep watch over fellow passengers.

The staffer told passengers they would be evacuated when it was safe to leave, but at that moment the safest place was on the train. He also urged people to maintain mobile phone batteries to be able to use their torches when they disembarked.

The passenger wrote: “In our carriage we’re well but we don’t know about the other carriages. There’s smoke and they’re calling for a doctor.”

Spanish media reports suggested a total of 400 people had been on the two trains.

The Spanish prime minister, Pedro Sánchez, said in a statement he was “closely monitoring” the situation.

The president of the Madrid region, Isabel Díaz Ayuso, said its hospitals were available to the Andalucía region if required.

Iryo is an Italian-run private rail operator. The company did not immediately respond to a request for comment.

Adif has suspended all rail services between Madrid and Andalucía.

Reuters contributed to this report