On May 10, 1801, Barbary pirates of Tripoli declared war on the United States of America (the first US foreign war). From the article:
"The Barbary Wars (1801-1815) aka Barbary Coast War or the Tripolitan War Barbary Wars The First Barbary War was an undeclared war waged by the United States against the North African states of Morocco, Tripoli, Algiers, and Tunis. The principle cause of the war was that those states harbored and supported the actions of pirates against American shipping vessels in the Mediterranean Sea. The war, which lasted from 1801 to 1805, did not completely end the acts of piracy against American vessels, but it did prove that the United States was capable of waging war, if necessary, in places far from its own shores.
The four Barbary States of North Africa – Morocco, Algiers, Tunis, and Tripoli – had plundered seaborne commerce for centuries. Surviving by blackmail, they received great sums of money, ships, and arms yearly from foreign powers in return for allowing the foreigners to trade in African ports and sail unmolested through the Barbary waters. They demanded tribute money, seized ships, and held crews for ransom or sold them into slavery.
During the Crusades (1095-1295), Muslim pirates operating from bases in North Africa had plundered ships carrying Crusaders and pilgrims and sold many Christians into slavery. By the sixteenth century, Hapsburg Spain and the Ottoman Turks were pitted in a struggle for supremacy in the Mediterranean. Piracy, which for both Christians and Muslims was a dimension of the conflict between the opposing powers, lured adventurers from around the Mediterranean to the Maghribi coastal towns and islands. Among them was Khair ad Din, called Barbarossa, who in 1510 seized Algiers on the pretext of defending it from the Spaniards. Barbarossa subsequently recognized the suzerainty of the Ottoman sultan over the territory that he controlled and was in turn appointed the sultan’s regent in the Maghrib. The term “Barbary” derives from Barbarosa ["red beard"].
By the end of the 18th Century the effectiveness of Tripoli’s corsairs had long since deteriorated, but their reputation alone was enough to prompt European maritime states to pay the tribute extorted by the pasha to ensure safe passage of their shipping through Tripolitanian waters. American merchant ships, no longer covered by British protection, were seized by Barbary pirates in the years after United States independence, and American crews were enslaved. In 1799 the United States agreed to pay $18,000 a year in return for a promise that Tripoli-based corsairs would not molest American ships. Similar agreements were made at the time with the rulers of Morocco, Algiers, and Tunis.
In May, 1801, the United States refused to succumb to the increasing demands of the Pacha of Tripoli; in return, the Pacha declared war against the States. While Tripoli was not a strong power and little effort was necessary to watch and blockade it, the fear was that the other Barbary powers would join against the United States. The United States sent naval squadrons into the Mediterranean under the slogan of “Millions for defense, but not one cent for tribute!” Under the leadership of Commodores Richard Dale and Edward Preble, the Navy blockaded the enemy coast, bombarded his shore fortresses, and engaged in close, bitterly contested gunboat actions.
On 16 February 1804 LT Stephen Decatur led 74 volunteers into Tripoli harbor to burn the captured American frigate The Philadelphia. British Admiral Lord Nelson called the raid “the most daring act of the age”. Boatswains Mate Ruben James volunteered to go on the raiding party. James was seriously wounded during hand-to-hand combat. Despite his wounds, or perhaps because of them, James put himself between an attacking pirate and the commander of that raid, Decatur, who remained uninjured thanks to James. Ruben James recovered from his wounds and continued to proudly serve his Navy for another 32 years. Lieutenant Stephen Decatur’s exploit in destroying the captured frigate USS Philadelphia, and Captain Richard Somers attempt with the fire-ship USS Intrepid to blow up enemy vessels in Tripoli harbor, set valorous examples for the young naval service.
In 1805 Marines stormed the Barbary pirates’ harbor fortress stronghold of Derna (Tripoli), commemorated in the Marine Corp Hymn invocation “To the Shores of Tripoli.” First Lieutenant O’Bannon is remembered for heroism in the battle for Derna. O’Bannon’s Marines were the first U.S. forces to hoist the flag over territory in the Old World. The “Mameluke” sword, carried by Marines officers today, was presented to O’Bannon in 1805.
In June 1805, Tobias Lear negotiated a peace settlement with the Pacha. However, this treaty was made only by stepping on the toes of William Eaton. William Eaton had been appointed consul to Tunis in 1798. When war was declared by Tripoli in 1801, he and special diplomat James L. Cathcart tried to work out a settlement. They believed that to effect a peace with that country, they needed to reinstate the exiled Hamet Karamanli to the throne. This ruler had been overthrown and exiled by his brother. Eaton returned to the states to present their plans to Congress. In 1804, he returned to the Mediterranean with the new title “Navy Agent to the Barbary States” and permission to carry out his plans. Just as Eaton was about to see his ideas come to fruition, he was suddenly ordered to leave Tripoli. Lear’s treaty was accepted instead and the phrase “to the shores of Tripoli” was added to the Marine’s battle hymn.
The Second Barbary War (1815), also known as the Algerine or Algerian War, was the second of two wars fought between the United States and the Ottoman Empire’s North African regencies of Tripoli, Tunis, and Algeria known collectively as the Barbary states. The war between the Barbary States and the U.S. ended in 1815; the international dispute would effectively be ended the following year by the United Kingdom and the Netherlands. The war brought an end to the American practice of paying tribute to the pirate states and helped mark the beginning of the end of piracy in that region, which had been rampant in the days of Ottoman domination (16th–18th centuries). Within decades, European powers built ever more sophisticated and expensive ships which the Barbary pirates could not match in numbers or technology.
Following the War of 1812 two naval squadrons under Commodores Decatur and Bainbridge returned to the Mediterranean. Diplomacy backed by resolute force soon brought the rulers of Barbary to terms and gained wide spread respect for the new American nation. Decatur obtained treaties which eliminated the United States paying tribute. In the years immediately after the Napoleonic wars, which ended in 1815, the European powers forced an end to piracy and the payment of tribute in the Barbary states.
After the First Barbary War, the European nations had been engaged in warfare with one another (and the U.S. with the British). However, in the years immediately following the Second Barbary War, there was no general European war. This allowed the Europeans to build up their resources and challenge Barbary power in the Mediterranean without distraction. Over the following century, Algiers and Tunis became colonies of France in 1830 and 1881 respectively, while Tripoli returned to the control of the Ottoman Empire in 1835. In 1911, taking advantage of the power vacuum left by the fading Ottoman Empire, Italy assumed control of Tripoli. Europeans remained in control of the government in eastern North Africa until the mid-20th century. By then the iron-clad warships of the late 19th century and dreadnoughts of the early 20th century ensured European dominance of the Mediterranean sea."