China's President Xi Jinping met Vietnam's leader Nguyen Phu Trong during a state visit to Hanoi (AFP)

The Communist leaders of China and Vietnam reached a "consensus" on handling the contested South China Sea, Chinese state media reported Sunday, hours after US President Donald Trump offered to mediate in the dispute.Chinese President Xi Jinping met with Vietnamese Communist Party chief Nguyen Phu Trong during a state visit to Hanoi on Sunday, after Trump also visited the country.Xinhua news agency reported that the Chinese and Vietnamese sides "reached an important consensus in accordance with leaders of the two parties and countries, to appropriately manage maritime issues, steadily advance all forms of maritime cooperation including joint development and jointly strive to uphold peace and stability in the South China Sea."The report did not provide more details about the agreement.China claims nearly all of the strategically vital sea, through which $5 trillion in shipping trade passes annually. It is also believed to sit atop vast oil and gas deposits.Vietnam, the Philippines, Malaysia, Brunei and Taiwan also have claims in the sea, and the dispute has long been seen as a potential trigger for conflict in Asia.Days after the US leader met with Xi in Beijing, Trump made a surprise offer to Vietnamese President Tran Dai Quang in Hanoi."If I can help mediate or arbitrate, please let me know... I am a very good mediator," Trump said.The offer could irritate the Chinese government as it has repeatedly said the United States has no role to play in what it insists is a series of bilateral issues.Vietnam has courted support from Washington in the row, in the face of Beijing's efforts in recent years to cement its claims by building artificial islands in disputed areas.Those islands are capable of serving as military bases, and some of the rival claimants are concerned that China will soon establish de facto control of the waters.Tensions spiked this year when Vietnam suspended an oil exploration project in an area of the sea also claimed by Beijing, reportedly over pressure from its powerhouse communist neighbour.

In 2014, China moved an oil rig into waters off Vietnam's coast, sparking violent protests in several Vietnamese cities.