Morocco was the first nation to recognise the fledgling United States as an independent nation in 1777. In the beginning of the American Revolution, American merchant ships in the Atlantic Ocean were subject to attack by the Barbary pirates. On December 20 1777, Morocco's Sultan Mohammed III declared that American merchant ships would be under the protection of the sultanate and could thus enjoy safe passage. The Moroccan–American Treaty of Friendship, signed in 1786, stands as the U.S's oldest non-broken friendship treaty.