The pasha, fearing the loss of power, then concluded a peace treaty with the Americans. As part of the treaty, all the American slaves held in Tripoli were freed. Thus ended the First Barbary War. However, this did not end the problem of piracy and the capture of Americans. A Second Barbary War ensued in 1815, which the US once again won. North African slave raiding declined only after 1830, when France conquered Algeria.