U.S. Defense Secretary Jim Mattis and his Chinese counterpart Wei Fenghe agreed Wednesday to bolster security dialogue to strengthen risk control, the Defense Ministry said, amid concerns over Beijing's growing assertiveness in the South China Sea.

With relations between the two countries soured over a tit-for-tat trade dispute, the defense chiefs apparently tried to avoid conflict in the security field, although Mattis has criticized China's military buildup in the contested waters.

"China and the United States should live in harmony," Mattis said during his meeting with Wei in Beijing, adding Washington is willing to promote "open dialogue" between the two countries, according to the ministry.

Wei, who assumed the current position in March, told Mattis that China and the United States must increase mutual trust and deepen cooperation in the security area, which would become a "stable factor" for bilateral relations, the ministry added.

Later Wednesday, Mattis met with Chinese President Xi Jinping, who has been seeking "win-win" cooperation with the United States.

Beijing "will not pursue expansionism and colonialism" and the wide Pacific Ocean "can accommodate China, the United States and other countries," Xi was quoted by state-run TV as telling Mattis.

"China-U.S. relations are one of the most important bilateral ties in the world," Xi added, China Central Television reported.

Meeting in the wake of the historic June 12 summit between U.S. President Donald Trump and North Korean leader Kim Jong Un, Mattis and Wei also discussed how to cooperate to achieve "complete denuclearization" of the Korean Peninsula.

Mattis, a former Marine general, is visiting China for the first time since becoming the Pentagon chief in January 2017. The last U.S. defense secretary to make a trip to China was Chuck Hagel in April 2014.

Prior to their meeting, Mattis invited the Chinese defense minister to visit the United States, U.S. media reported.

China has rapidly built artificial islands with military infrastructure in the South China Sea in recent years. U.S. warships have also carried out "freedom of navigation" operations there apparently to challenge Chinese claims and activities in the waters.

In the South China Sea, home to some of the world's busiest sea lanes, China and several Southeast Asian countries have overlapping territorial claims. Beijing contends that U.S. actions in the sea challenge its sovereignty and security interests.

Mattis said earlier this month that China's placement of weapons systems on territory it controls in the South China Sea is "for the purposes of intimidation and coercion."

The Trump administration has designated China as a "strategic competitor" that could threaten the international order.

China and the United States have suffered setbacks in their efforts to expand military cooperation, owing to the maritime row and differences over how to deal with North Korea's ballistic missile and nuclear development programs.

In May, the Pentagon withdrew an invitation to China to take part in the Rim of the Pacific exercise, a U.S.-led biennial multinational naval drill, citing China's actions in the South China Sea that "only serve to raise tensions and destabilize the region."

Ahead of his arrival in Beijing on Tuesday, Mattis told reporters that the United States is keen to review its military relations with China in line with the National Security Strategy he unveiled in January, adding that the two countries should establish a "transparent strategic dialogue."

Mattis's visit to China comes a week after the United States and South Korea agreed to suspend a major joint military exercise held every August that North Korea views as provocative.

The United States believes that China's cooperation is essential to compel North Korea, which relies on trade with its giant neighbor, to abandon its nuclear weapons.

China has proposed a "double suspension" approach, where North Korea would suspend its nuclear and missile activities in exchange for the United States and South Korea suspending their joint military drills.

After his three-day trip to China through Thursday, the defense secretary is scheduled to travel to South Korea and Japan.

In recent months, the United States and China, the world's two biggest economies, have been exchanging threats of retaliatory tariffs, with Trump aiming to reduce huge U.S. trade deficit with China ahead of November's midterm congressional elections.