BEIJING (Reuters) - Common interests between China and Vietnam far outweigh differences, Chinese President Xi Jinping told Vietnam's prime minister on Tuesday, calling for their dispute in the South China Sea to be resolved through talks.

China claims almost all of the South China Sea, where about $5 trillion worth of seaborne trade passes every year. Brunei, Malaysia, the Philippines, Taiwan and Vietnam also have claims in the sea, believed to have rich deposits of oil and gas.

Vietnam is in the midst of a quiet military buildup analysts say is designed as a deterrent, to secure its 200 nautical mile Exclusive Economic Zone, as China grows more assertive in staking its claims in the South China Sea.

A court of arbitration in The Hague in July said China's claims to the waterway were invalid, after a case was brought by the Philippines. Beijing has refused to recognize the ruling.

Vietnam welcomed the ruling, saying it strongly supports peaceful resolution of disputes, while reasserting its own sovereignty claims.

Meeting in Beijing, Xi told Vietnamese Prime Minister Nguyen Xuan Phuc that "China and Vietnam can manage their differences and promote maritime cooperation through friendly negotiations", the official Xinhua news agency said.

"The common interests between the two countries far outweigh the differences," it paraphrased Xi as saying.

The South China Sea issue should be resolved by bilateral consultations and maritime challenges transformed into opportunities for cooperation, Xi added.

Phuc met Chinese Premier Li Keqiang a day earlier.

Li told Phuc that the South China Sea involved both issues of sovereignty and maritime rights as well as "national feelings", China's Foreign Ministry said on Tuesday.

"China and Vietnam should work hard together, scrupulously abide by their high level consensus, maintain maritime stability, manage and control disputes, promote maritime cooperation, continue to accumulate consensus, jointly maintain maritime and regional peace and stability and create conditions for the stable development of bilateral ties," Li said.

The ministry cited Phuc as saying maritime issues should be appropriately handled in a peaceful way on the basis of equality and mutual respect and not allow maritime issues to affect the development of relations.

Earlier this month, Indian Prime Minister Narendra Modi offered Vietnam a credit line of half a billion dollars for defense cooperation.

The offer comes after a surge of almost 700 percent in Vietnam's defense procurements as of 2015, according to the Stockholm International Peace Research Institute think tank, which tracks the arms trade over five-year periods.

(Reporting by Ben Blanchard; Editing by Michael Perry)