BEIJING/TAIPEI (Reuters) - China accused the United States on Thursday of interfering in its internal affairs and said it had lodged a complaint after U.S. President Donald Trump signed into law an act laying the groundwork for possible U.S. navy visits to self-ruled Taiwan.

Chinese Foreign Ministry spokesman Lu Kang drinks a cup of water at a regular news conference in Beijing, October 27, 2015. REUTERS/Kim Kyung-Hoon

Tensions have risen in recent days after a senior Chinese diplomat threatened China would invade Taiwan if any U.S. warships made port visits to the island which China claims as its own territory.

On Monday, Chinese jets carried out “island encirclement patrols” around Taiwan, with state media showing pictures of bombers with cruise missiles slung under their wings as they carried out the exercise.

On Tuesday, Trump signed into law the National Defense Authorization Act for the 2018 fiscal year, which authorizes the possibility of mutual visits by navy vessels between Taiwan and the United States.

Such visits would be the first since the United States ended formal diplomatic relations with Taiwan in 1979 and established ties with Beijing.

Chinese Foreign Ministry spokesman Lu Kang said while the Taiwan sections of the law were not legally binding, they seriously violate the “One China” policy and “constitute an interference in China’s internal affairs”.

“China is resolutely opposed to this, and we have already lodged stern representations with the U.S. government,” Lu told a daily news briefing.

China is firmly opposed to any official exchanges, military contact, or arms sales between Taiwan and the United States, he added.

Proudly democratic Taiwan has become increasingly concerned with the ramped up Chinese military presence, that has included several rounds of Chinese air force drills around the island in recent months.

Taiwan is confident of its defenses and responded quickly to the Chinese air force drills this week, its government said, denouncing the rise in China’s military deployments as irresponsible.

Taiwan presidential spokesman Alex Huang, speaking to Taiwan media in comments reported late on Wednesday, said the defense ministry had kept a close watch on the patrols and responded immediately and properly.

Taiwan “can ensure there are no concerns at all about national security, and people can rest assured”, Huang said.

Both sides of the narrow Taiwan Strait, which separates Taiwan from its giant neighbor, have a responsibility to protect peace and stability, he added.

“Such a raised military posture that may impact upon and harm regional peace and stability and cross-strait ties does not give a feeling of responsibility, and the international community does not look favorably upon this,” Huang was quoted as saying.

Relations have soured considerably since Tsai Ing-wen, who leads Taiwan’s independence-leaning Democratic Progressive Party, won presidential elections last year.

China suspects Tsai wants to declare the island’s formal independence, a red line for Beijing. Tsai says she wants to maintain peace with China but will defend Taiwan’s security.

Taiwan is well equipped with mostly U.S. weapons but has been pressing for more advanced equipment to deal with what it sees as a rising threat from China. The United States is bound by law to provide the island with the means to defend itself.

China has never renounced the use of force to bring Taiwan under its control.