People stuck in the traffic jam caused by the accident were also killed in the blast that left a crater 65 feet wide and 9 feet deep near the town of Nadadores in the northern state of Coahuila, witnesses and officials said.
There were body parts scattered in the trees, said Paulina Luna, 62, a local resident who was evacuated to a shelter. Her brother's home was flattened. The house was swept from the earth as if it never existed, she said.
The tractor-trailer had collided with a pickup and burst into flames. Firemen at the scene were trying to put out the blaze when they ran out of water. Moments later there was a huge explosion that almost obliterated the rig.
We were waiting about 100 meters (300 feet) from the crash when there was an incredibly loud bang. Suddenly there were flying rocks and a fireball, said Silverio Alfonso Amador, 44, who was in the traffic jam and survived the explosion.
His face was covered with burns and his ears stuffed with cotton wool.
At least 29 people were killed and around 150 injured, up to 30 of them in serious condition in local hospitals, state officials said. Radio stations reported that about 40 people had died.
Around 260 people living close to the site in a small desert roadside village called Selemania were evacuated.
An army explosives expert at the scene told Reuters the tractor-trailer was carrying 25 metric tons of ANFO, a mixture of ammonium nitrate and fuel oil used widely in the mining industry. Coahuila is a major mining state.
Soldiers and police cordoned off an area up to a mile around the site of the blast, which badly damaged eight houses and blew out the windows of 60 others.
Witnesses said 26 wrecked and charred cars were hauled away from the scene. TV images showed a body hanging from a power line.
We found part of the engine, Coahuila state police chief Fausto Destenave-Kuri told Reuters. The truck practically disintegrated.
Three of the dead were local journalists.
Reporters who were taking photographs died there as well as emergency workers and drivers who stopped to help, state Gov. Humberto Moreira said.
(Additional reporting by Gabriela Lopez and Tomas Bravo)