Rail network operator Adif said the collision happened at 19:45 local time (18:45 GMT) on Sunday, about an hour after one of the trains left Málaga heading north to Madrid, when it derailed on a straight stretch of track near the city of Córdoba.
The force of the crash pushed the carriages of the second train into an embankment, according to Transport Minister Óscar Puente. He added that most of those killed and injured were in the front carriages of the second train, which was travelling south from Madrid to Huelva.
Rescue teams said the twisted wreckage of the trains made it difficult to recover people trapped inside the carriages.
Sanchez visited the site of the crash with senior officials on Monday afternoon.
"This is a day of sorrow for all of Spain, for our entire country," he told reporters.
"We are going to get to the truth, we are going to find the answer, and when that answer about the origin and cause of this tragedy is known, as it could not be otherwise, with absolute transparency and absolute clarity, we will make it public."
Puente said an investigation could take at least a month, describing the incident as "extremely strange".