BEIJING—China said it would sanction any U.S. firm involved in a planned $8 billion sale of advanced jet fighters to Taiwan, in retaliation against what it describes as Washington’s attempt to undermine Chinese national security.

Beijing’s countermeasure against the proposed sale of 66 F-16V fighters isn’t expected to have much impact on the manufacturer, Lockheed Martin Corp. , but it could complicate efforts to resolve the U.S.-China trade dispute.

“China will take all necessary measures to safeguard its interests, including the imposition of sanctions against the American companies that participate in this arms sale to Taiwan,” Chinese Foreign Ministry spokesman Geng Shuang said Wednesday.

Beijing considers the self-ruled island of Taiwan as part of its territory and refuses to rule out achieving unification by force. China repeatedly has criticized U.S. arms sales to Taiwan as harmful to its sovereignty.

If Washington goes through with the F-16V sale, all of the ensuing consequences must be borne by the U.S., Mr. Geng said, without elaborating.