Panama has established diplomatic ties with China and broken with Taiwan in a major victory for Beijing, which continues to lure away the dwindling number of countries that have formal relations with the self-ruled island.
Panamanian President Juan Carlos Varela said in a televised address on Monday that Panama was upgrading its commercial ties with China and establishing full diplomatic links with the second most important customer of its key shipping canal.
"I'm convinced that this is the correct path for our country," Varela said.
Taiwan's government said it was sorry and angry over Panama's decision, and said it would not compete with China in what it described as a "diplomatic money game".
"Our government expresses serious objections and strong condemnation in response to China enticing Panama to cut ties with us, confining our international space and offending the people of Taiwan," David Lee, Taiwan's minister of foreign affairs, told a briefing in Taipei.
Taiwan would immediately end cooperation with and assistance for Panama, and evacuate embassy and technical personnel "in order to safeguard our national sovereignty and dignity", Lee said.
China is deeply suspicious of Taiwan President Tsai Ing-wen, who it thinks wants to push for the island's formal independence, although she says she wants to maintain peace with Beijing.
China and Taiwan have tried to poach each other's allies over the years, often dangling generous aid packages in front of developing nations, although Taipei struggles to compete with an increasingly powerful China.
Panama is the second country to switch its recognition to Beijing since Tsai took office last year, following a similar move by Sao Tome and Principe in December, trimming to 20 the number of countries that formally recognise Taiwan.
Taiwan had as many as 30 diplomatic allies in the mid-1990s, and its remaining formal ties are with mostly smaller and poorer nations in Latin America and the Pacific.
China's Foreign Minister Wang Yi met his counterpart from Panama, Isabel de Saint Malo, in Beijing on Tuesday and signed a joint communiqué establishing ties.
"This is a historic moment. China-Panama relations have opened a new chapter," Wang said, describing Panama's decision as in "complete accordance" with its people's interests and "in keeping with the times".
"The two countries' governments agreed to develop good friendly relations on the principles of mutual respecting sovereignty and territorial integrity, non-aggression, mutual non-interference in internal affairs, mutual benefit, and peaceful coexistence," China's Foreign Ministry said in a statement on its website.
Panama's government said in a statement that it recognised there was only one China, with Taiwan belonging to the Asian giant, and that it was severing ties with Taipei.
"The Panamanian government is today breaking its 'diplomatic ties' with Taiwan, and pledges to end all relations or official contact with Taiwan," the statement said.
The establishment of links with Panama is a coup for China, which has been showering largesse on countries throughout Central America in recent years in an attempt to get them to break ties with Taiwan.
As recently as December, Panama's deputy foreign minister had said he did not expect any change in Panama's relations with Taiwan or China.
Panama is one of Taiwan's oldest friends, but some diplomats in Beijing had speculated that the Central American country could become the next nation to break ties.
Tsai visited Central American allies earlier this year but did not stop in Panama.
In Beijing, Panama's foreign minister de Saint Malo said President Varela had expressed 10 years ago his interest in establishing ties with China, and that she hoped the move would lead to trade, investment and tourism opportunities, especially for "exporting more goods from Panama to China".
Monday's diplomatic move could also raise questions about the future of a Chinese-backed project to build another Central American waterway to rival the Panama Canal in Nicaragua.
Earmarked at a cost of $50 billion, the Nicaraguan scheme was met with widespread incredulity when it was announced in 2013, and critics have raised questions about its feasibility.