Another 28 people were injured -- 20 of them severely -- and were being treated at seven local hospitals, San Antonio Police Chief William McManus and Fire Chief Charles Hood told reporters.
The police chief said the group included children, but later told CNN that the eight dead were adult men.
He said the truck driver had been arrested.
"We got a call from a Walmart employee about a welfare check in a tractor-trailer that was parked on the lot here," McManus told a news conference.
"He was approached by someone from that truck, who was asking for water."
The employee returned with the water and then called the police who "found eight people dead in the back of that trailer," the police chief said, calling it a "horrific tragedy."
He said store security footage showed that some vehicles came to pick up some travellers who were on the truck and who had made it out alive.
"We're looking at a human trafficking crime this evening," he added.
It was not immediately clear how many people may have survived and fled, McManus said.
Hood said the air conditioner in the trailer was not working.
"We started extricating patients out of the back of a semi-truck … we had another 20 patients that were either in extremely critical condition or very serious condition and they have been transported to a number of hospitals."
San Antonio lies a few hours drive from the border with Mexico's Nuevo Leon state. Weather in the area has been hot and dry.
Federal immigration officials with Immigration and Customs Enforcement have also been notified, the police chief said.
McManus said the deadly discovery, sadly "is not an isolated incident".
"This happens quite frequently under cover of night," he said.
Illegal migration over the US border with Mexico is an everyday fact. Most of the migrants are from Mexico and Central America seeking better-paying work in the United States.
"Fortunately there are people who survived, but this happens all the time," he said.
There have been many cases of migrants -- often scores at a time -- stranded and killed in northern Mexico when the truck they are being moved in was abandoned in heat by drivers.
The smugglers in their haste to evade authorities often leave passengers without air conditioning, and often without air to breathe.