A spokesman for Foxconn said the company was investigating the cause of the incident. But analysts say worker unrest in China has grown more common because workers are more aware of their rights, and yet have few outlets to challenge or negotiate with their employers.

When they do, though, the results can be ugly and, because of social media and the Web, almost instantly transmitted to the world in their rawest and most unfiltered form.

“At first it was a conflict between the security guards and some workers,” said a man who was reached by telephone after he posted images online. The man said he was a Foxconn employee. “But I think the real reason is they were frustrated with life.”

The company said that as many as 2,000 workers were involved in the incident but that it was confined to an employee dormitory and “no production facilities or equipment have been affected.”

Nonetheless, the plant was closed, the company said.

Foxconn, which is based in Taiwan and employs more than 1.1 million workers in China, declined to say whether the Taiyuan plant made products for the Apple iPhone 5, which went on sale last week. A spokesman said the factory supplied goods to many consumer electronics brands. An employee at the Taiyuan plant said iPhone components were made there.