In December 1777, the Moroccan Sultan Mohammed III included the United States in a list of countries to which Morocco's ports were open. Morocco thus became the first country whose head of state publicly recognized the newly-independent United States. Relations were formalized with the Moroccan–American Treaty of Friendship, which was negotiated by Thomas Barclay in Marrakesh and signed by American diplomats in Europe, Thomas Jefferson, and John Adams with Sultan Mohammed III in 1786.