Beginning in 2007, tainted heparin (a blood thinner) imported from China was linked to the deaths of 149 American patients. It was a stark example of a growing problem.

China is now the largest supplier of pharmaceutical chemicals—hundreds of tons annually—to the world. And pharmaceutical companies that buy these chemicals do test them. When Illinois-based Baxter Healthcare sourced cheap heparin from China in 2007, for example, it carried out all legally required tests. But the tests it used at the...