President Donald Trump visits the Forbidden City with China's President Xi Jinping in Beijing on November 8, 2017.

U.S. President Donald Trump said on Sunday he was prepared to mediate between claimants to the South China Sea, where five countries contest China's sweeping claims to the busy waterway.

Trump was speaking in Vietnam, which has become the most vocal opponent of China's claims and its construction and militarization of artificial islands in the sea. About $3-trillion in goods passes through the sea each year.

"If I can help mediate or arbitrate, please let me know," Trump said in comments at a meeting in Hanoi with Vietnam's president, Tran Dai Quang.

Trump acknowledged that China's position on the South China Sea was a problem.

"I'm a very good mediator and arbitrator," he said. President Quang said Vietnam believed in handling disputes on the South China Sea through peaceful negotiations and on the basis of international laws - which Vietnam says nullify China's claims.

Vietnam has reclaimed land around reefs and islets, but on nowhere near the same scale as China. Brunei, Malaysia, the Philippines and Taiwan also have claims in the sea.

Since Philippine President Rodrigo Duterte has grown closer to China, Vietnam has emerged as China's main challenger in the region. In July, China pressured Vietnam to stop oil drilling in a disputed area, taking relations to a low.

Relations have since improved and Chinese President Xi Jinping is visiting Hanoi later on Sunday.