NOTE: although Morocco was a close ally and friend of the USA from the very beginning of our country, this was not the case with other Muslim countries along the coast of N. Africa, the so-called "Barbary States", named after the "Berber race" which dominates this area. Note that before the Muslim religion existed, King Herod of Israel was of Berber descent, and was chosen by the Romans to rule Israel when Jesus Christ was alive as a human on earth from the year 0 A.D.
The term, "Barbary Pirate" should maybe be "Barbary Privateers", since they worked for sovereign governments, presumably. But calling them "pirate" is also accurate since the brand new USA was not at war with the "Barbary States" of northern Africa, until President Jefferson declared war on those sponsors of the ships attacking U. S. ships.
The U. S. Government under Presidents Washington, Adams, Jefferson, and Madison, was threatened with bankruptcy, domination, and slavery by the Barbary Pirates.
The U. S. Navy was re-created by Presidents George Washington and later, John Adams, along with the U. S. Congress and Senate beginning in 1794 mainly in response to attacks in the Mediterranean Sea on U. S. merchant ships, and the enslavement of their crews and passengers, by the so-called "Barbary Pirates". These civilians were freed only when ransom or tribute was paid for their release. Later, some U. S. Navy and Marines sent to rescue those civilians were also captured and kept enslaved unless ransom was paid. If the ransom was not paid, the captives were subject to being sold into a more permanent slavery. (The first act to build the ships and create the new U. S. Navy was signed by President Washington, but the need ended when diplomacy and tribute improved relations with the pirate state. Then when things deteriorated, again, the act to establish the new U. S. Navy was later signed by President Adams after those ships were built. The need for the Navy fluctuated as diplomatic relations changed with the pirate state.)
The ultimate victory by the brand new and tiny reconstituted U. S. Navy with European allies over these forces was not a sure thing, and I wish to point out that if the USA and allies had lost this war, it is conceivable that the U. S. as an independent country might have collapsed, and President Jefferson and/or President Madison could've been sold into slavery in North Africa, along with hundreds of U. S. Marines and U. S. Navy personnel. Logistically this seems impossible today, but such things had gone on in white-man Europe for hundreds of years.
Rescuing presumably white U. S. civilians captured and enslaved in N. Africa was the goal of this war waged by the U. S. Navy and U. S. Marines with allies for a few decades before, during and just after the much larger War of 1812.
Until the Napoleonic Wars were over, the general population of continental Europe and Britain who were often immigrating to the new USA were not necessarily considered free people before reaching the USA, often being captured in coastal areas all over Europe and Britain, and sold into slavery in Northern Africa, just as white U. S. citizens were occasionally so treated.
Black people were not the only people sometimes enslaved around the world before abolition finally prevailed in Europe and the Americas.
How come we don't know about this already? I think the general population of the USA does not wish to remember the wars with the Barbary Pirates and "white European and American slavery".
America's very first war as a new nation! Yet, I recall that in school, we studied The War with the Barbary Pirates for about 2 or 3 minutes. That's all I remember! But I did not really comprehend what this war was about. I remember knowing NOTHING about it, really.
I rediscovered this war with "pirates" while studying the causes for the War of 1812, which is also a war largely ignored in American schools. I had noticed that we fought the War of 1812 due partly to the continued British impressment of American sailors involuntarily into the Royal Navy (of the U.K.). In other words, a form of bondage by the British for (white) American citizens still existed after the American Revolution!
After the supposedly victorious American Revolution of 1775-1783, freedom for the inhabitants of the USA, was at hand, but not fully guaranteed. For example, some of the British wanted some or all of their former citizens, and territories in North America, back.
Despite the American victory of the 1776 revolution which supposedly ended in 1783, the whole world 1775-1815 was a very difficult and dangerous place for Americans in which to live until modern times. Just traveling around the world was very dangerous for Americans until the modern era, The world seemed to be dominated by all sorts of pirates who traded in slaves of every race, including white Americans and Europeans.
Coastal areas in all of Europe were particularly very vulnerable and dangerous due to pirate raids and kidnappings. In fact, in Spain, coastal villages went mostly extinct until pirate raids had been successfully suppressed. This also helps explain why Spanish immigration numbers to the Spanish colonial possessions were so limited compared to immigration counts to the British colonies.
In the latter part of the 19th century, the coastal kidnapping theme was still popular in English literature, but presented in a totally different environment and situation: such as the popular book, Kidnapped, by Robert Louis Stevenson, that has nothing to do with Muslim pirates, but rather trouble with an evil uncle.
Funny how recent Scottish history earlier in the 19th century was so quickly forgotten by the masses. They wanted to forget it, I suppose.