China’s President Xi Jinping said during a visit to Vietnam Friday that the two countries need to work together to promote trust and cooperation, calling its fellow communist state a “close comrade.”

Analysts say Mr. Xi’s visit is partly designed to project a softer image of China here and arrest the souring relationship between the two countries. Speaking to a gathering of young people from Vietnam and China in Hanoi Friday, Mr. Xi said the two countries need to work on building trust and cooperation for their mutual benefit. A Vietnamese translation of Mr. Xi’s book on governance was also released shortly before his arrival.

The two neighbors have a prickly relationship and fought a brief but bitter border war in 1979, but share a common ideology and approach to economic development. Top leaders from Vietnam frequently visit their counterparts in Beijing.

Carlyle Thayer, a Vietnam expert and emeritus professor at the University of New South Wales at the Australian Defense Force Academy, said Mr. Xi is trying to improve how China is perceived among a new generation of communist leaders in Vietnam, some of whom may rise to senior positions during Vietnam’s Communist Party congress next year. Party General Secretary Nguyen Phu Trong, Prime Minister Nguyen Tan Dung and President Truong Tan Sang are all expected to step down from their current posts.

Tensions between the two countries have risen in recent years in part because of territorial disputes in the South China Sea. A Chinese company last year dragged a large oil-drilling rig into waters also claimed by Vietnam, triggering a monthslong standoff at sea and a brief wave of anti-Chinese riots before the rig was withdrawn. More recently, China’s moves to step up its construction of artificial islands on semi-submerged reefs and atolls in the region have ratcheted tensions higher. Mr. Xi’s visit, which began Thursday, has been accompanied by sporadic anti-Chinese protests which were quickly broken up by police.

Mr. Xi’s visit is also aimed at expanding and strengthening the economic ties between the two countries. Despite Vietnam’s growing influence as a global exporter, China remains its single largest trading partner—a point Mr. Xi emphasized during his remarks. China provides many of the raw materials and machinery that Vietnam uses to produce garments, footwear and electronic goods.

By VU TRONG KHANH, November 5, 2015 in the Wall Street Journal