In 1801, the pasha of Tripoli demanded that the U.S. increase its tribute after they released crew members of two recently captured American ships. Jefferson refused and instead, ordered a naval expedition to the Mediterranean, which resulted in the First Barbary War (1801-1805) with Morocco and Tripoli.
The battles were mostly naval, but it was on land that the U.S. won the war. Through military action and diplomacy, as well as using tactics similar to those of the Green Berets today, Tripoli was forced into a treaty that ended the war in 1805.
Within a few decades, the coast of North Africa and the Barbary rulers fell to European imperialism.