From left, Chinese State Councilor and Defense Minister General Wei Fenghe, Chinese Politburo Member Yang Jiechi, Secretary of State Mike Pompeo, and Secretary of Defense Jim Mattis, participate in a news conference at the State Department in Washington, Friday, Nov. 9, 2018. (AP Photo/Carolyn Kaster)

Secretary of Defense Jim Mattis, left, Secretary of State Mike Pompeo, second from left, Chinese Politburo Member Yang Jiechi, third from right, and Chinese State Councilor and Defense Minister General Wei Fenghe, second from right, meet at the State Department in Washington, Friday, Nov. 9, 2018. (AP Photo/Carolyn Kaster)

Defense Secretary Jim Mattis and Chinese Minister of Defense General Wei Fenghe, stand as the national anthems are played during an enhanced honor cordon at the Pentagon, Friday, Nov. 9, 2018. (AP Photo/Pablo Martinez Monsivais)

Defense Secretary Jim Mattis and Chinese Minister of Defense General Wei Fenghe, stand as the national anthems are played during an welcome ceremony at the Pentagon, Friday, Nov. 9, 2018. (AP Photo/Pablo Martinez Monsivais)

Secretary of State Mike Pompeo, right, shakes hands with Chinese Politburo Member Yang Jiechi at the conclusion of a news conference at the State Department in Washington, Friday, Nov. 9, 2018. (AP Photo/Carolyn Kaster)

WASHINGTON (AP) — 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 Friday that set the stage for a meeting between President Donald Trump and President Xi Jinping later this month.

The U.S. pushed back, 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."