A fire official said 16 people, including four children, had also been taken to hospital.
The survivors were “hot to the touch” and suffering from heat stroke and heat exhaustion.
San Antonio, which is 250km (150 miles) from the US-Mexican border, is a major transit route for people-smugglers.
Human traffickers often use lorries to transport undocumented migrants after meeting them in remote areas once they have managed to cross into the United States.
“They had families… and were likely trying to find a better life,” San Antonio Mayor Ron Nirenberg said. “It’s nothing short of a horrific, human tragedy.”
Emergency responders initially arrived at the scene at about 18:00 local time (23:00 GMT) after responding to reports of a dead body, San Antonio fire chief Charles Hood told reporters.
“We’re not supposed to open up a truck and see stacks of bodies in there. None of us come to work imagining that,” he said.
He added that the vehicle, which had been abandoned by its driver, had no working air conditioning and there was no drinking water inside it.
San Antonio’s climate is blisteringly hot in the summer months, with temperatures there reaching 39.4C (103F) on Monday.
Mexico’s Foreign Minister, Marcelo Ebrard, said that two Guatemalans were among those taken to hospital. The nationalities of the other victims was not immediately clear.
Three people are being held in custody and the investigation has been handed over to federal agents.
Mexican Consul General Rubén Minutti has been dispatched to the scene, while the consulate in San Antonio said it would provide “all the support” if Mexican citizens are among the dead.
A horrific scene
Angelica Casas in San Antonio
It’s dark now and only a few law enforcement vehicles and some police tape cordoning off a dark road make evident that this is the scene of a mass casualty event.
The victims, presumed to be migrants, likely died of heat exhaustion or dehydration.
Edward Reyna, a security guard at a lumber yard just yards away, said he was not surprised to arrive for his night shift and hear this news.
He’s lost count of the times he’s seen migrants jumping off the train that passes right next to where the lorry was found.
“I thought sooner or later, somebody was going to get hurt,” Mr Reyna said. “The cartels that bring them over don’t care about them.”
This story has played out in San Antonio before, but not to this magnitude.
In 2017, 10 immigrants were found dead inside a similar tractor trailer outside a Walmart – also on the city’s south side.
San Antonio’s far south side is a corridor with two main highways connecting the city to Texas border towns.
Mostly rural communities, a few junkyards and a handful of developing neighbourhoods in this part of San Antonio make it easy for a lorry this size to go unnoticed – until it doesn’t.
US Secretary of Homeland Security Alejandro Mayorkas, whose department has taken over the investigation, said: “Human smugglers are callous individuals who have no regard for the vulnerable people they exploit and endanger in order to make a profit.”
Texas’s Republican Governor Greg Abbott blamed US President Joe Biden for the deaths, describing them as a “result of his deadly open border policies”.
Beto O’Rourke, the Democratic candidate running against Mr Abbott, said the reports were devastating and called for urgent action to “dismantle human smuggling rings and replace them with expanded avenues for legal migration”.
Immigration is a contentious political issue in the United States, where in May a record 239,000 undocumented migrants were detained crossing into the country from Mexico – many traveling along extremely risky and unsafe routes.
US law enforcement officials are on track to exceed the record 1.73 million border arrests made in 2021, with large numbers of people continuing to cross from Central American countries such as Honduras, Guatemala and El Salvador.
Fleeing poverty and violence in Central America, many of the undocumented migrants end up paying huge sums of cash to people-smugglers to get them across the US border.
Over recent years, there have been many similar examples of migrants perishing during their journey, but no single event as deadly as what was discovered on Monday.
After the tragedy was discovered, the Catholic Archbishop of San Antonio, Gustavo Garcia-Siller tweeted: “Lord have mercy on them. They hoped for a better life.”
“Once again, the lack of courage to deal with immigration reform is killing and destroying lives,” he added.
Speaking to the BBC from San Antonio, KENS5 local reporter Matt Houston said: “It is our understanding right now that if this is a human smuggling incident – as it appears – it would be the deadliest of its kind in American history.”
He said the risks faced by families crossing into the United States were formidable – and in recent days, the area had been struck by a heatwave.