China will take necessary countermeasures to foreign interference regarding the new Hong Kong security legislation being deliberated, the foreign ministry said on Wednesday.