Police in the US state of Texas have arrested a truck driver whose vehicle was found in a Walmart car park with dozens of people in the back of it.
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 38C (100F).
Police say they believe the incident is linked to people smuggling.
The truck's driver, named by authorities as James Mathew Bradley Jr, 60, of Clearwater, Florida, is expected to appear in court later.
Video footage from the store 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.
'Human tragedy in our city'
San Antonio Mayor Ron Nirenberg told the BBC that caring for the victims was the authorities' first aim.
"Our most important focus right now is to deliver compassionate care," he said.
"You know our first responders immediately were on the scene, delivering first aid, transporting - sometimes by air - critical condition patients to local hospitals, and trying to prevent more loss of life than what had already occurred."
"We are working with authorities, we are working with... witnesses to understand the magnitude of these crimes.
"But in this case, where we are witnesses to a human tragedy in our city, our first response and our response as local officials is to render aid."
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.
The US attorney for the Western District of Texas, Richard Durbin, 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", he added.
Experts say people smuggling is a serious issue in southern Texas, and there have been a number of similar cases in the area just in this past month.
On 7 July, US Border Patrol agents found 72 undocumented immigrants from Central American countries locked inside a trailer "with no means of escape".
The next day 33 people were found locked inside a trailer at a checkpoint on the road to San Antonio.