BEIJING — China says it is temporarily barring most foreigners from entering the country as it seeks to curb the number of imported coronavirus cases.

The foreign ministry announced late Thursday that even foreign citizens with residence permits will be prevented from entering starting on Saturday. All visa-free transit policies will also be temporarily suspended.

It said diplomatic workers will be exempt, and foreign citizens coming to China for “necessary economic, trade, scientific or technological activities or out of emergency humanitarian needs” can still apply for visas.

The ministry said in a statement that: “The suspension is a temporary measure that China is compelled to take in light of the outbreak situation and the practices of other countries.”

The coronavirus outbreak originated in China. But as its number of domestic virus cases has dwindled, the country has had to contend with infections brought by people who have recently arrived from overseas. Such infections have accounted for the majority of China’s new cases for more than a week.