Nine men had died inside, and 28 others, including children, were taken to hospital.
They were inside the trailer in San Antonio without access to air conditioning or water while outside temperatures hit 110F.
Police say they believe the incident is linked to people smuggling.
The truck’s driver, named by authorities as 60-year-old James Mathew Bradley Jr. from Clearwater, Florida, is expected to appear in court later.
Video footage from Walmart reportedly showed a number of vehicles arriving to pick up some of the survivors. Several others may have managed to escape on foot into the woods nearby.
One person found in the woods was being treated, local officials said.
Mexico’s government said it was working closely with US authorities to identify the nationalities of the victims.
San Antonio is a few hours’ drive from the border with Mexico, and the US immigration department is trying to establish the victims’ legal status.
Eight people were found to be dead at the scene while another died in hospital, immigration officials said.
Officials were brought to the trailer by a man who had approached an employee of the Walmart and asked for water.
The driver would be charged in connection with the “horrible tragedy”, said San Antonio police chief William McManus in a press briefing.
He said the people ranged from school age to in their 30s.
Local fire chief Charles Hood said the survivors had heart rates of over 130 beats per minute and were very hot to touch. In addition to the 20 people in a critical condition, eight others were taken to hospital in a less severe state.
The fire chief confirmed at least two of the victims were school-age children. Their condition is not clear.
“We’re very fortunate that there weren’t 38 of these people who were all locked inside this vehicle dead,” he added.
Richard Durbin, the US attorney for the Western District of Texas, said the authorities were working to identify those responsible for the incident.
“These people were helpless in the hands of their transporters. Imagine their suffering, trapped in a stifling trailer in 100-plus degree heat,” he said in a statement.
They were victims of “ruthless human smugglers indifferent to the wellbeing of their fragile cargo”, Richard Durbin added.
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…