In the early 19th century war broke out between the United States and Tripolitania, and a series of battles ensued in what came to be known as the First Barbary War and the Second Barbary War. By 1819, the various treaties of the Napoleonic Wars had forced the Barbary states to give up piracy almost entirely, and Tripolitania's economy began to crumble. As Yusuf weakened, factions sprung up around his three sons. Civil war soon resulted.