HANOI/BEIJING (REUTERS) - Vietnam agreed to build a "truly trustworthy" relationship with China on Friday during a visit to Hanoi by its President Xi Jinping, but at the same time invited Beijing's old rival Japan for joint military exercises and a visit to a sought-after port.
The diplomatic flurry highlights the fragility of China's testy ties with its communist neighbour, and Vietnam's efforts to diversify its relations through new alliances with states locked in bitter disputes with Beijing over its maritime expansionism.
Vietnam and China's competing territorial claims mushroomed into a major dispute last year, which Mr Xi aimed to settle on a timely visit close to a scheduled shake-up of a Vietnamese Communist Party leadership that is increasingly being courted by the United States.
Mr Xi was given the red carpet treatment during meetings since Thursday with the top leaders of Vietnam and he told its National Assembly their joint revolutionary friendship could dispel and survive any "disruptions".
"Our two parties, countries and peoples should be staunch in their faith, help each other and proceed hand in hand, not allowing anyone to disrupt our pace," he said.
Both sides agreed on Friday to maintain peace at sea and trust each other, but as Mr Xi prepared to leave, Japan's defence ministry announced Vietnam had invited it to take part in humanitarian exercises and to bring a warship to its strategic Cam Ranh Bay once construction of a new dock was complete.
Japan and China have their own territorial dispute in the East China Sea, complicating a relationship coloured by Japan's occupation of parts of China before and during World War Two.
Cam Ranh is the jewel in the crown of Vietnam's military, with an air base once used by US and Soviet forces, and a deep water bay home to its modern, Russian-built submarines. Visits by foreign ships are rare and usually reserved for maintenance.
MATTER OF TRUST
Vietnam's warm assurances to China and its agreement with Japan on the same day are likely to antagonise Beijing, but show Hanoi's intent to engage the West and Asian powers in defence, trade and investment after a history of dependence - which have been uncomfortable at times - on its giant neighbour.
Trust has become an issue for China, whose Foreign Minister Wang Yi on Friday told US counterpart John Kerry that a recent US warship patrol near its man-made islands in the Spratlys was of extreme concern.
A website run by China's official People's Daily newspaper displayed rare pictures on Friday of the reclamation work, taken by a worker on Mischief Reef, showing diggers and tractors dumping sand into the azure waters.
China's parking of an oil rig unannounced in waters off Vietnam's coast in May 2014 was widely seen as a miscalculation that has given the United States and allies like Japan an opening to steer Hanoi away from Beijing's orbit.
China's reclamation of reefs near the contested Spratly Islands has fuelled resentment and put Vietnam's rulers in a difficult position, pressured from nationalists and even some party members to take a tougher line, but wary of incurring China's wrath. It is unclear what kind of leadership will emerge from the secretive party's congress in January.
Mr Xi referred to Vietnam's independence hero Ho Chi Minh and his amity with the founder of modern China, Mao Zedong, and their similar political systems.
He made no mention of the South China Sea and referred only to "tests" both had faced in the winds of history. Relations, he added, must "not be allowed to stray from the correct path".
Vietnamese President Truong Tan Sang told Mr Xi that relations had been hurt and made a rare admission about concerns within the Communist Party.
"The trust in the relationship... was reduced among the public, cadres and party members due to disputes and disagreements," he said, according to a foreign ministry statement.
Mr Sang "urged both sides to enhance political trust building, cooperation, actively seek to resolve satisfactorily existing problems", it said.