China is the second-biggest client of the Panama Canal and the leading provider of merchandise to a free-commerce zone in the Panamanian city of Colon.

Panama switched diplomatic relations from Taiwan to China on Tuesday, dealing a major victory to Beijing in its drive to isolate the self-governing island it claims as its own territory.

In Panama, President Juan Carlos Varela announced the change, which entails breaking off formal relations with Taiwan, saying in a televised address that it represents the “correct path for our country.”

A joint statement released on Monday evening in Panama said Panama and China were recognizing each other and establishing ambassadorial-level relations the same day.

“The Government of the Republic of Panama recognizes that there is but one China in the world, that the Government of the People’s Republic of China is the sole legal government representing the whole of China, and that Taiwan is an inalienable part of China’s territory,” the statement read.

“The Government of the Republic of Panama severs ‘diplomatic relations’ with Taiwan as of this day and undertakes not to have any more official relations or official exchanges with Taiwan,” it continued.

Panama had been among the largest economies to have maintained diplomatic relations with Taiwan. The island now has just 20 formal diplomatic partners, 12 of which are in Latin America and the Caribbean. The island is also excluded from the United Nations and many other multinational bodies at China’s insistence.

At the Diaoyutai state guesthouse in Beijing on Tuesday, Chinese Foreign Minister Wang Yi and Panamanian Vice President and Foreign Minister Isabel de Saint Malo signed a joint communique establishing diplomatic relations, followed by a champagne toast.

Mr. Wang said he was sure relations between the two countries would have a “bright future.”

Saint Malo said she hoped the new relationship would lead to trade, investment and tourism opportunities, in particular “exporting more goods from Panama to China.”

China and Taiwan split amid civil war in 1949 and Beijing has vowed to take control of the island by force if necessary.

While the sides had maintained an undeclared diplomatic truce for much of the past decade, relations have deteriorated under current Taiwanese President Tsai Ing—wen, who took office more than a year ago but has declined to endorse China’s view that Taiwan and the mainland are part of a single Chinese nation.

The past year has seen China ratcheting up the diplomatic pressure on Taiwan, barring its representatives from attending the World Health Organization’s annual conference and other international gatherings.

Beijing cut off contacts with Taiwanese government bodies a year ago, and in recent months has also sailed an aircraft carrier strike force aground the island in a display of its growing military power.

Taiwan’s Ministry of Foreign Affairs said in a statement that in breaking ties, President Varela had ignored the friendship between their countries and the efforts that Taiwan had made to help Panama’s overall development. Panama had “submitted to the Beijing authorities for economic benefits” and “lied” to the government of Taiwan, the statement said.

Taiwan will immediately cut ties, cease all bilateral cooperation projects and pull its diplomatic staff and technical advisers out of the country, the ministry said, adding that it will not “engage in competition for money diplomacy with the Beijing authorities.”

“We express our strong protest and condemnation over the Beijing authorities luring Panama into breaking ties with us, oppressing our diplomatic space to maneuver and harming the feelings of the Taiwanese people,” the statement said.

Beijing and Taipei have long competed with each other to win diplomatic recognition, at times enticing small or poor countries to switch with the promise of millions of dollars for public works projects.

Varela had suggested the possibility of switching diplomatic recognition during his presidential campaign in 2014, for historic, economic and strategic reasons.

“Both nations are betting on a more interconnected world,” Varela said in a possible allusion to Chinese economic involvement in the Panama Canal. He mentioned that it was a massive Chinese vessel that was the first to pass through the canal’s expanded locks when they opened in June 2016.

China is the second-biggest client of the Panama Canal and the leading provider of merchandise to a free-commerce zone in the Panamanian city of Colon, on the country’s Caribbean coast.