SHANGHAI — The sister ship of an American guided missile destroyer that sailed last month in waters claimed by China is in Shanghai for a weeklong port visit, in a sign that although the United States strongly disagrees with actions by China in the South China Sea, their two navies still value good relations.

The commander of the United States Pacific Fleet, Adm. Scott H. Swift, had flown to Shanghai on Monday to be on board the visiting ship, the Stethem, when it arrived.

He said he was invited to China a month ago — relatively short notice for such a high-level visit — by a Chinese vice admiral, Su Zhiqian. Their meeting on board the Stethem on Tuesday stretched from a scheduled 30 minutes to two hours, Admiral Swift said.

“We acknowledged the policy differences between our two countries, but we have a responsibility as maritime commanders that friction points in policy don’t become friction points at sea,” the admiral said in an interview with reporters on the Stethem.