Moroccan–American Treaty of Friendship

In December 1777, the Moroccan Sultan Muhammad 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 (also known as the Treaty of Marrakesh) negotiated by Thomas Barclay in Marrakesh, and signed by American diplomats in Europe, Thomas Jefferson, John Adams with Sultan  Muhammad III in 1786.

Situation in Morocco
Muhammad III, or Sidi Muhammad ibn Abdallah, came to power in 1757 and ruled until his death in 1790. Prior to his reign, Morocco had experienced 30 years of internecine battles, instability and turmoil. During the 33 years Sidi Muhammad ruled he transformed the politics, the economy and the society, putting development of international trade high on his agenda and restoring power to the sultanate. This served to quickly bring respect to Morocco on the international scene. Central to his pursuit of international trade was the negotiation of agreements with foreign commercial powers. He actively began seeking one with the United States well before the war with Great Britain was settled in 1783, finally got America's attention in 1784, and warmly welcomed Thomas Barclay's arrival to negotiate in 1786. The treaty signed by Barclay and the sultan, then by Jefferson and Adams, was ratified by the Confederation Congress in July 1787. It has withstood transatlantic stresses and strains for more than 232 years, making it the longest unbroken treaty relationship in United States history.