The First Barbary War was a conflict between the United States, Sweden, and the Kingdom of Sicily against the Barbary states of North Africa, including Tunis, Algiers, and Tripoli. It lasted from May 10, 1801, to June 10, 1805, and was primarily a response to piracy in the Mediterranean.