Panama broke off diplomatic relations with Taiwan and switched to Beijing, accepting its "One China" policy, the countries announced Monday.
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.
"In light of the interests and wishes of both peoples, the Republic of Panama and People's Republic of China have decided to grant each other, from the date of this document's signing, mutual recognition, establishment of diplomatic ties at the ambassadorial level," the note said.
Panama's government earlier said in a statement 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 announcement comes after Beijing began construction last week of a container port, with natural gas facilities, in Panama's northern province of Colon.
Taiwan, considered a rebel province by Beijing, is recognised by around 20 countries worldwide and the issue of its status has risen again with the election of US President Donald Trump.
Panama long had stressed it had diplomatic ties with Taipei and commercial ones with Beijing.
Today, Chinese ships are the number two users of the Panama Canal, the Central American country's main source of budget revenue.
Panama over the years received generous aid, millions of dollars in cooperation funds from Taipei. But it was simultaneously pressed for decades by Beijing to adopt its stand.
One China policy
The dispute arose in December after Trump, elected president a month earlier, spoke to Taiwan's president by telephone.
Trump became the first president or president-elect to speak to a Taiwanese leader since at least 1979, when the United States severed diplomatic ties with Taiwan as part of its recognition of the People's Republic of China.
In the statement, Trump's office said the two leaders had noted "the close economic, political, and security ties" between Taiwan and the United States, but the very contact threatened to upend almost four decades of US foreign policy.
After years of heavy rhetoric, relations between China and Taiwan started improving in the 1980s. China put forward a formula, known as "one country, two systems", under which Taiwan would be given significant autonomy if it accepted Chinese reunification.
The offer was rejected, but Taiwan did relax rules on visits to and investment in China. There were also limited talks between the two sides' unofficial representatives.
But Chinese concern arose in 2000 when Taiwan elected Chen Shui-bian, who had openly backed independence, as president.
Chen was re-elected in 2004, prompting China to pass a law the following year, stating China's right to use "non-peaceful means" against Taiwan if it tried to secede from China.
Former Panama president arrested in the US
Former Panama president Ricardo Martinelli was arrested in Florida, US on charges of using public money to spy illegally on his rivals while in office. He is accused of spying on more than a 150 rivals during his 2009-2014 term as the president.
Martinelli was taken into custody near a home in Miami, Florida on Monday evening. Panama's supreme court issued a warrant for Martinelli's arrest in December 2015 after he failed to appear at a Panamanian court hearing on his case.