BEIJING—China's government is scrambling to move about 1,200 Chinese workers in northern Iraq out of the path of the violent insurgency that is sweeping through large swaths of the country.

The workers, employed by China Machinery Engineering Corp., are building a fuel oil power station in the city of Samarra and have been trapped by the fighting since at least late last week, according to a statement from the company and state media reports.