Barbary Wars, 2 wars waged by the United States against African states. Barbary pirates had been attacking ships in the Mediterranean since the 16th century. In May 1801, the United States blockaded Tripoli in opposition to exorbitant payments to the Barbary States to protect its shipping. The United States won the war in 1805. The second Barbary War was fought in 1815 with Algiers. Treaties ending piracy were signed with Algiers, Tunis, and Tripoli.