Few things are more ridiculous in international politics than when a former enemy offers to mediate disputes between two former allies. But that’s exactly what happened when US President Donald Trump told Vietnamese counterpart Tran Dai Quang he could help solve the long-standing territorial disputes between China and Vietnam in the South China Sea. A little more than 40 years ago the two communist countries were comrades-in-arms against the US in the Vietnam war.

Trump’s offer in Hanoi on Sunday of last week came just hours before his Chinese counterpart Xi Jinping began his second state visit in three years to the former communist ally. It also came soon after a summit in Beijing that highlighted Trump’s “bromance” with Xi. The leaders of the world’s two largest economies both visited Hanoi after attending the Asia-Pacific Economic Co-operation summit in the Vietnamese port city of Da Nang on November 10. Trump’s overtures to Hanoi – which have the potential to antagonise Beijing – betray the fact that relations between Washington and Hanoi and Washington and Beijing are both stronger than those between the two communist former allies.

China and Vietnam were often described as being “as close as lips and teeth” during the era of their communist founders, Mao Zedong and Ho Chi Minh. China provided substantive support, including troops, to Vietnamese communists in their decades-long struggle for national independence. It was not until 1979 when relations were broken off following the outbreak of their border war. Ties were normalised in 1991 when both countries shifted their focus to economic development.

It’s time for Trump to come clean on his vision for Asia

WATCH: Seven top moments from Donald Trump’s Asia visit

In recent years, however, China’s increasingly assertive foreign policy amid escalating territorial disputes in the South China Sea have pushed the United States and Vietnam closer together, as Hanoi has moved to diversify its strategic and economic engagements.

Vietnam has also taken steps to improve relations with China’s other rivals – Japan and India – and consolidate its regional engagements bilaterally and through the Association of Southeast Asian Nations.

Many people find it surprising that the Vietnamese are more forgiving to the Americans than the Chinese, despite the millions of deaths caused by the Vietnam war – sometimes referred to as the Second Indochina War – between 1955 and 1975. Recent opinion polls have suggested that the US is the most favoured country of the Vietnamese – and China the least favoured. Last year, a Pew survey found 84 per cent of Vietnamese viewed America favourably, up from 76 per cent in 2014; only 10 per cent of them viewed China favourably, down from 16 per cent. In a 2014 survey, 77 per cent of Vietnamese viewed Japan positively and 67 per cent saw India favourably. Polls by Pew also suggest nearly all Vietnamese people – 95 per cent – support capitalism. No other country polled was beyond 90 per cent, even the US. Some Vietnamese even imagine that if the US and South Vietnam had won, Vietnam would now be better off as it would be in line with capitalist societies like Singapore, South Korea, and Taiwan.

Apparently, many Vietnamese see the threat from the US as being in the past, and are happy to leave it in the past. But they see the threat from China as being in the here and now. Memories of the brief but bloody border war in 1979 linger – as do memories of China’s seizures of the Paracel and Spratly Islands, which Vietnam claims as its territory.

Opinion: Can Asia handle parallel rise of strongmen Xi and Abe?

Many Vietnamese point out the US invasion lasted just two decades, while Vietnam’s tensions with China have persisted for thousands of years, from a millennium of Chinese rule to the confrontations of the past century. Hanoi’s aim may be to leverage the two powers to maintain its non-aligned diplomatic status, but the balance of the scale appears to be tilting towards stronger relations with Washington than with Beijing.

Cary Huang, a senior writer with the South China Morning Post, has been a China affairs columnist since the 1990s