HANOI, Vietnam -- Leaders of China and Vietnam agreed Thursday to limit their differences and maintain peace and stability, as the two Communist neighbours attempt to repair ties strained over territorial disputes in the South China Sea.

Chinese President Xi Jinping received a rare 21-gun salute before he and Vietnamese Communist Party chief Nguyen Phu Trong headed for talks behind closed doors.

The two leaders agreed to promote relations between their countries and the ruling Communist parties, Vietnam's Foreign Ministry said.

Xi said China will "strive together with Vietnam to well control differences at sea, and maintain overall China-Vietnam relations and peace and stability" in the South China Sea, the ministry said in a statement.

Trong told Xi that the two countries should not allow territorial disputes to affect their relations, and proposed that they not take any actions that increase tensions or the militarization of the South China Sea, the ministry said.

Bilateral relations plunged last year following China's parking of a giant oil rig near the disputed Paracel islands, which sparked deadly anti-Chinese riots in Vietnam.

The two countries have since tried to repair ties with high-level contacts including a trip by Trong to China last April.

Trong and Xi also witnessed the signing of a dozen co-operation agreements covering party-to-party relations, investment, infrastructure, culture and a $200 million loan from the China Development Bank to the Bank of Investment and Development of Vietnam.

But analysts said Xi's two-day visit is unlikely to mark much progress in addressing the territorial tensions.

"I personally think it's difficult to resolve the issue of territorial disputes when Vietnam and China still maintain their positions," said Duong Danh Dy, the former Vietnamese consul general in Guangzhou, in southern China.

Xinhua said in a commentary that settling their territorial disputes depends on "the two neighbours' will and ability to properly manage their differences," and that they should not allow the outside world to interfere.

Witnesses said about 30 people protested briefly in front of the Chinese Embassy in Hanoi on Thursday morning before authorities took them away in buses.

China claims sovereignty over almost all of the South China Sea, parts of which are also claimed by several of its neighbours. Vietnam and China have rival claims to the Paracel islands, which China occupied after ousting soldiers from the U.S.-backed South Vietnamese government in 1974, one year before the end of the Vietnam War.

Massive land reclamation by China over the past 18 months in the South China Sea has rattled countries in the region and caused concern in the United States, which supports the freedom of navigation and overflight in the area.

Despite the territorial disputes, China is Vietnam's largest trading partner, with two-way trade reaching $58 billion last year.

Xi is scheduled to speak to Vietnam's lawmaking National Assembly on Friday, a rare address by a foreign head of state.

The Chinese president is to travel on Friday to Singapore, where he is to have talks with Taiwan's president, in the first such meeting since Taiwan split from mainland China in 1949.