Morocco was the first country to recognize the independence of the United States.
In 1777, Sultan Mohammed ben Abdallah opened Moroccan ports to American ships and treated them favorably alongside vessels from nations with treaty relations. This action amounted to an early recognition of the new United States during the American Revolutionary War.
The formal diplomatic relationship developed later. Morocco and the United States signed a Treaty of Peace and Friendship in 1786, and the Confederation Congress ratified it in 1787. The treaty remains one of the longest-running treaty relationships in American history.
France is often remembered as America’s most important early ally because it signed treaties with the United States in 1778 and provided military and financial assistance. Spain also supported the American cause, but neither country was first to recognize U.S. independence.