KABUL—Secretary of State John Kerry visited Afghanistan on Monday to shore up a troubled alliance, following concessions by the U.S. that appeared to have quelled President Hamid Karzai's complaints about American respect for Afghan sovereignty.

Mr. Kerry's visit to Kabul, his first as secretary of state, coincided with the handover on Monday of the main U.S. detention facility in the country to Afghan control, resolving a major...