By Roberta Rampton and Michael Martina
HANGZHOU, China (Reuters) - U.S. President Barack Obama on Saturday pressed his Chinese counterpart Xi Jinping on territorial disputes in the South China Sea, urging Beijing to uphold its legal obligations and stressing the United States' commitments to its regional allies.
Tensions over the disputed waters between China and its neighbors were expected to hang over the G20 summit, which opens in the eastern Chinese city of Hangzhou on Sunday.
China is keen to ensure a smooth summit, its highest profile event of the year, as it looks to enhance its global standing and avoid acrimony over a long list of tensions with Washington.
Obama, now in the last five months of his presidency, wants to put a final stamp on his signature policy shift toward the Pacific, setting the tone for his White House successor, who will be elected in November and take office on Jan. 20.
He has invested in developing closer ties with nations in Southeast Asia, and is taking pains in his last scheduled trip to the region to reassure partners worried about the economic and military might of China.
After more than four hours of meetings with Xi and his top officials, Obama emphasized the importance for China to "abide by its obligations" to an international maritime treaty in the dispute over rights to a territory rich in oil and fish through which $5 trillion in trade travels each year.
An arbitration court in The Hague ruled in July that China had no historic title over the waters of the South China Sea and had infringed on the rights of the Philippines, which brought the case under the U.N. Convention on the Law of the Sea.
China rejected the ruling and accused the United States of stirring up trouble in the sea where its territorial claims overlap in parts with Vietnam, the Philippines, Malaysia, Brunei and Taiwan.
"China will continue to firmly safeguard its sovereignty and maritime rights in the South China Sea," Xi said according to a statement on the foreign ministry's website.
"At the same time, it will persist in peacefully resolving disputes through consultations with parties directly involved," Xi said, urging the United States to "play a constructive role" in the peace and stability of the region.
In an unusually lengthy statement following the meeting, the White House said Obama had "underscored the United States' unwavering commitment to the security of its treaty allies."
"The president reaffirmed that the United States will work with all countries in the region to uphold the principles of international law, unimpeded lawful commerce, and freedom of navigation and over-flight," the White House said.
'CANDID' TALKS, ENDING IN A NIGHTTIME STROLL
Obama is at his last summit of the world's 20 major economies, and the White House said the Hangzhou visit would likely be his final meeting as president with Xi, with whom he has grappled over hacking incidents, commercial tensions, and differences over human rights.
Obama stressed the need for a "an open trade and investment environment" and "the need for China to protect religious freedom for all of its citizens," the White House said.
China rejects criticism of its human rights record, arguing it has lifted millions out of poverty.
Cyber issues, from concern over hacking and cyber espionage to emerging Chinese policies on information technology that foreign companies fear could limit their operations in the country, have also strained ties.
The visit got off to a rocky start when a Chinese government official angrily scuffled with Obama's top national security adviser, Susan Rice, at the airport, and yelled at a press aide.
Obama and Xi tried to strike a cooperative tone, formally agreeing to join the Paris agreement to curb climate-warming emissions, a deal they worked together to cement.
But then they got down to more thorny issues. For his part, Xi told Obama that China objects to the deployment of a U.S. missile shield in South Korea to help protect against the North Korean nuclear threat.
Xi also told Obama it was the responsibility of China and the United States to carry out a successful G20 summit and to "inject momentum to the global economy while lifting confidence," Xinhua said.
The leaders met for more than four hours, first flanked by their top security and economic advisers, and later talking one-on-one as they took a night-time stroll around the picturesque West Lake, where Xi is hosting the G20 summit.
Video footage of the walk showed Xi asking Obama about his daily exercise routine, and describing growth and change in the region as the leaders sat down for tea.
"We're also setting the stage so that the next U.S. administration comes in with a relationship that is on a strong and productive footing," Obama told Xi.
(Reporting by Roberta Rampton; Writing by Michael Martina; Editing by Gareth Jones and James Dalgleish)