During the visit, China and Vietnam agreed to step up co-operation on security matters in their move towards becoming a community with a "shared future", they said on Wednesday, as Xi wrapped up a visit to Hanoi.
On Xi's two-day trip, the Communist-ruled neighbours, close in economic areas but at odds over boundaries in the South China Sea, signed dozens of co-operation pacts and agreed to set up more hotlines to defuse any emergencies in the contested waters.
Xi has pushed hard for the upgrade in ties, especially after Vietnam elevated the United States in September to the highest tier of its diplomatic ranking, the same as China's.
Xi's visit to Vietnam, which is home to a growing number of Chinese manufacturers, is only his fourth overseas this year after trips to Russia, South Africa and the United States.