The Barbary states declared jihad (holy war) against Christian nations, which allowed them to attack "infidel" ships legally under Islamic law. They saw themselves as holy warriors and naval soldiers, not common thieves. This religious veneer made their brutality feel righteous to them, and utterly terrifying to their victims.