BEIJING — When Defense Secretary Jim Mattis met with President Xi Jinping of China on Wednesday, he hoped to start a conversation on China’s position in the South China Sea. He left knowing just how firm Mr. Xi is on the issue.

“We cannot lose even one inch of the territory left behind by our ancestors,” Mr. Xi told him, according to Chinese state media. “What is other people’s, we do not want at all.”

Disagreements between Washington and Beijing over the Chinese military’s expanding presence in the South China Sea and the American policy toward Taiwan were two of the most prominent issues raised during meetings between Mr. Mattis and senior officials in Beijing, the first stop on a trip that will take him to South Korea and Japan.

Mr. Mattis, who has assailed the Chinese military for its expansion in the South China Sea, made clear the Pentagon’s stance on contested waters, stressing the need for freedom of navigation in the region and China’s adherence to international law, according to defense officials who spoke on condition of anonymity.