SAN ANTONIO — The authorities here discovered eight bodies in a tractor-trailer in a Walmart parking lot early Sunday morning in what they said was a human trafficking crime that underscored the perils facing migrants trying to enter the United States by any means available.

By Sunday afternoon, another person had died at a hospital, according to a spokesman for Immigration and Customs Enforcement. All of the dead were men.

The eight people whose bodies were initially found were believed to have died from heat exposure and asphyxiation, a spokesman for the San Antonio Police Department said.

Federal officials said in a statement on Sunday that 39 people had been in the trailer. The city’s fire chief, Charles Hood, said at a news conference that 30 were taken to hospitals; about 20 were in “extremely severe” or critical condition.

In a statement, Mayor Ron Nirenberg of San Antonio called the episode “tragic,” adding that it “shines a bright light on the plight of immigrants looking for a better life and victims of human trafficking.”

Smuggling migrants in the backs of trucks is a common form of human smuggling in the region, and it has claimed lives in the past.

An expert on border enforcement and migrant deaths called the trucks “mobile ovens.”

“Those things are made out of steel and metal,” the expert, Néstor P. Rodríguez, a professor of sociology at the University of Texas at Austin, said on Sunday. “Yesterday in Austin, it was like 96 degrees at 9:30 in the evening. Even if the cooling system is on in the tractor-trailer, it’s just too hot.”

The San Antonio police chief, William McManus, said at a predawn news conference that a store employee making the rounds late Saturday night had been approached by someone from the truck “asking for water.” The employee returned with the water and called the police, who found the bodies.

Chief McManus said that “we’re looking at a human trafficking crime here” and that officials from the Department of Homeland Security and Immigration and Customs Enforcement were helping with the investigation.

Two of those found were “school-age children,” and the others were in their 20s and 30s, the chief said. The two youngest of those hospitalized were 15, the authorities said. The bodies were taken to the Bexar County Medical Examiner’s Office to determine the cause of death. Details about the victims were unavailable.

The driver, identified as James M. Bradley Jr., 60, of Clearwater, Fla., is in custody and will be charged, the top federal prosecutor in the San Antonio area said in a statement on Sunday.

“These people were helpless in the hands of their transporters,” said the prosecutor, Richard L. Durbin Jr., the United States attorney for the Western District of Texas. “Imagine their suffering, trapped in a stifling trailer in 100-plus-degree heat.”

No further details were available about how long the truck had been in the parking lot of the Walmart, which is on the southwestern side of the city, or where it had come from. Chief McManus said surveillance video showed that several vehicles had approached the trailer to pick up people. Some occupants fled into the woods nearby, and the police chief said officers would search on foot and by air.

Chief Hood said the air-conditioning in the truck had not been working, adding that those found were “very hot to the touch.”

Of the survivors, he said, “our paramedics and firefighters found that each one of them had heart rates over about 130 beats per minute.”

A spokesman for Customs and Border Protection, the parent agency of the Border Patrol, said on Sunday that the people in the truck were probably migrants who had crossed the Mexican border on foot and been taken to a stash house before being put in the tractor-trailer to be transported farther north.

The grisly discovery on Sunday was made more than 100 miles from the site of a similar episode of mass migrant deaths 14 years ago. In May 2003, 19 undocumented immigrants suffocated and died in the trailer of a milk truck that was found abandoned near Victoria.

Dozens of immigrants, crammed inside the milk truck’s trailer, struggled to survive temperatures as high as 173 degrees as the truck traveled along South Texas highways. Those inside clawed at the truck’s insulation and broke out a taillight in an attempt to get air and alert drivers.

On Sunday in San Antonio, Celia and Nicole Pérez were home across the street from the Walmart around 1 a.m. when a loud noise woke them up. They saw helicopters and police lights circling their backyard.

They first thought it was a mass shooting. “The cops were blocking the entrance to Walmart,” Celia Pérez said. “Immigration was the last thing on my mind.”

About a year ago, Nicole Pérez said her grandmother, who lives nearby, saw as many as 20 immigrants dash through her yard.