Until the American Declaration of Independence in 1776, British treaties with the North African states protected American ships from the Barbary corsairs. Morocco, which in 1777 was the first independent nation to publicly recognize the United States, became in 1784 the first Barbary power to seize an American vessel after independence. While the United States managed to secure peace treaties, these obliged it to pay tribute for protection from attack. Payments in ransom and tribute to the Barbary states amounted to 20% of United States government annual expenditures in 1800, leading to the Barbary Wars that ended the payment of tribute. However, Algiers broke the 1805 peace treaty after only two years, and subsequently refused to implement the 1815 treaty until compelled to do so by Britain in 1816.