Updated

China bluntly told the United States to stop sending ships and military aircraft close to islands claimed by Beijing in the South China Sea, during talks that set the stage for a meeting between President Donald Trump and President Xi Jinping later this month.

The U.S. pushed back Friday, insisting it will continue to "fly, sail and operate wherever international law allows." In late September, U.S. and Chinese vessels nearly collided near a disputed reef.

Despite the frank airing of differences at the meeting in Washington of the two nations' top diplomats and military chiefs, both sides stressed the need to tamp down tensions, which have flared amid a bitter trade dispute that Trump and Xi are expected to tackle at the Group of 20 summit in Argentina.

"The United States is not pursuing a policy of Cold War containment with China," Secretary of State Mike Pompeo told reporters following the U.S.-China Diplomatic and Security Dialogue. "Rather we want to ensure that China acts responsibly and fairly in support of security and prosperity of each of our two countries."

The talks were due to be held in Beijing last month but were postponed after Washington announced new arms sales to Taiwan, and after a Chinese destroyer came close to the USS Decatur in late September in what the U.S. Navy called an "unsafe and unprofessional maneuver." Beijing has sweeping but disputed sovereignty claims in the area.

"The Chinese side made it clear to the United States that it should stop sending its vessels and military aircraft close to Chinese islands and reefs and stop actions that undermine Chinese authority and security interests," said Pompeo's Chinese counterpart, Yang Jiechi, who also had sharp words over U.S. support for Taiwan.

However, Yang and Chinese defense minister Wei Fenghe spoke of the need to improve cooperation, including between the U.S. and Chinese militaries, to ease the risk of conflict as the two powers jockey for pre-eminence in the Asia-Pacific.

"Cooperation is the only option for us," Wei said. "Confrontation and conflict between the two militaries will spell disaster for us all."

Defense Secretary Jim Mattis asserted U.S. rights to freedom of navigation but also said the two sides should work together on areas of common interest. "Competition does not mean hostility. Nor must it lead to conflict," Mattis said.

Although the rescheduling of the dialogue signaled an effort by the two sides to contain the slide in the relationship, it did not address the core dispute on trade. Trump has slapped tariffs on $250 billion in Chinese products, in a push to narrow the U.S. trade deficit and push back against what the U.S. views as predatory Chinese tactics on the high technology industry. Beijing has retaliated with tariffs on $110 million worth of U.S. goods.

Yun Sun, a China expert at the Stimson Center think tank, said Beijing is uncertain about what exactly Trump wants out of a trade deal, but hopes that with U.S. midterm elections out of the way, the mercurial American president may be more inclined to reach a compromise. "Their top priority is to stabilize relations," she said.

On human rights, Pompeo voiced concern over China's treatment of religious minorities, including the mass detention of minority Uighur Muslims. But overall, the tone of the U.S. officials' public comments was milder than that of the Chinese. Yang insisted that Chinese people have freedom of religion, and that "foreign countries have no right to interfere."