BEIJING — China announced on Monday that it would ban all variants of the powerful opioid fentanyl, a move that could slow the supply of a drug that in recent years has caused tens of thousands of overdose deaths in the United States.

By declaring that all varieties of fentanyl are now controlled substances, China made good on a pledge that the Chinese leader, Xi Jinping, made to President Trump late last year.

China’s export of the drug, which American officials say accounts for the vast majority of the fentanyl that ends up in the United States, has long been a source of tension in relations. More recently, it has also become tangled up in the continuing trade war.

China already treats more than two dozen variants of fentanyl and its precursors as controlled substances, thus strictly regulating their production and distribution, but it has banned those variants only after reviewing them case by case, a process that can be lengthy. And because so many more variants exist, and new ones are constantly being created, banning them as a broadly defined class could be far more effective.