Barack Obama’s visit to Vietnam has made for some attractive images of crowds lining the streets of Hanoi to cheer the leader of a power that was once a relentless foe, or of the US president sitting on a plastic stool during a stop at a pavement restaurant to taste the local pork-and-noodle bun cha. But behind the smiles and photo ops, hard-headed geopolitics was at work too.

The visit to Vietnam was a good opportunity to emphasise two overarching themes that Mr Obama has placed at the centre of his diplomacy: his willingness to turn the page on old grievances inherited from the cold war, and his focus on rebalancing US strategic priorities towards Asia, the region to which global power is shifting. But deciding how those choices could be squared with a message on fundamental values and human rights quickly became more complicated than he perhaps expected.

Mr Obama is not the first US president to visit Vietnam (Bill Clinton did so 16 years ago) but the symbolism of this trip is one that has been carefully calibrated. After all, Mr Obama once described himself as “America’s first Pacific president”, in a reference to his childhood partly spent in Indonesia, and in 2011 he announced that the US would “turn its attention to the vast potential” of Asia. The historical resonances of the trip were also bound to consolidate the image of a president who has always been unenthusiastic about large-scale American military forays, and who has shown himself ready, on several occasions, to acknowledge America’s past errors or failures. After opening up to Iran and Cuba, Vietnam was no doubt another milestone for Mr Obama, who is due to visit Hiroshima on Friday.

All of this was surely signalled when the US president gave a speech to a packed auditorium of Vietnamese Communist officials and promised to work towards a new partnership. It was also there when he said, to loud applause: “Big nations should not bully smaller ones.” In his speech, he acknowledged the enduring “ache” left by the Vietnam war. But while working to dispel the shadows of the past, the key message concerned today’s balance of power in Asia.

The “big nation” that Vietnam worries about these days is not the US, but China. It is China’s growing assertiveness in claiming waters off Vietnam’s coast in the South China Sea that has pushed the Hanoi regime to prioritise deeper ties with Washington. That had a lot to do with Mr Obama’s announcement of a complete lifting of the US arms embargo on Vietnam. The president also made a renewed commitment to the wide-ranging free-trade agreement the US has offered 11 Asian and Pacific nations – an agreement China is not part of.

Yet the price of the strategic rapprochement is that human rights have been all but marginalised. It is true that Mr Obama met a group of Vietnamese civil society activists in Hanoi and made the case for better governance through respect for universal values in his speech. But the lifting of the arms embargo – a move that US diplomacy had long asserted was dependent on Vietnam improving its human rights record – was granted without any serious bargaining. It was not a good sign that Mr Obama expressed only regrets after several of the activists who were supposed to meet him were stopped from doing so by security forces, who in some cases put them under house arrest just before the visit started.

Vietnam remains a repressive state. The Communist hold on power is total. Dissenting voices are routinely silenced, as they were this month when environmental protesters were rounded up in several cities. Geopolitical calculus not human rights dominated this trip. That’s perhaps understandable in the tense regional context. But the outcome is that the hopes of those Vietnamese who expected a boost for basic freedoms were largely spurned. That too is part of Mr Obama’s foreign policy legacy.