BEIJING — A blaze roared through an apartment building on the blue-collar edge of Beijing, killing at least 19 people, many of whom were apparently migrant workers from the Chinese countryside who were trapped in acrid smoke, officials and local residents said on Sunday.

The fire broke out Saturday evening in a two-story structure in the Daxing District, about 11 miles south of the Chinese capital’s prosperous downtown. Around 6 p.m., the flames began consuming the building, and thick smoke spilled into the air. Firefighters spent three hours battling the fire, according to a news release from Daxing officials.

Eight people were injured, and a “suspect” was being detained, the statement said. The release did not say whether the person had been accused of deliberately starting the fire, or of negligence.

Residents who gathered near the gutted structure on Sunday said the smoke from the fire had been thick and smelled of chemicals. They declined to give their names, apparently wary of speaking freely in front of the police and officials who were watching the crowd and preventing people, including reporters, from getting within a few hundreds yards of the site.