When American colonists rebelled against British rule in 1776,
American merchant ships lost Royal Navy protection. With no
American Navy for protection, American ships were attacked and
their Christian crews enslaved by Muslim pirates operating under
the control of the "Dey of Algiers"--an Islamist warlord ruling
Algeria.
Because American commerce in the Mediterranean was being destroyed
by the pirates, the Continental Congress agreed in 1784 to
negotiate treaties with the four Barbary States. Congress appointed
a special commission consisting of John Adams, Thomas Jefferson,
and Benjamin Franklin, to oversee the negotiations.
Lacking the ability to protect its merchant ships in the
Mediterranean, the new America government tried to appease the
Muslim slavers by agreeing to pay tribute and ransoms in order to
retrieve seized American ships and buy the freedom of enslaved
sailors.
Adams argued in favor of paying tribute as the cheapest way to get
American commerce in the Mediterranean moving again. Jefferson was
opposed. He believed there would be no end to the demands for
tribute and wanted matters settled "through the medium of war." He
proposed a league of trading nations to force an end to Muslim
piracy.
In 1786, Jefferson, then the American ambassador to France, and
Adams, then the American ambassador to Britain, met in London with
Sidi Haji Abdul Rahman Adja, the "Dey of Algiers" ambassador to
Britain.
The Americans wanted to negotiate a peace treaty based on Congress'
vote to appease.
During the meeting Jefferson and Adams asked the Dey's
ambassador why Muslims held so much hostility towards America, a
nation with which they had no previous contacts.
In a later meeting with the American Congress, the two future
presidents reported that Ambassador Sidi Haji Abdul Rahman Adja had
answered that Islam "was founded on the Laws of their Prophet, that
it was written in their Quran, that all nations who should not have
acknowledged their authority were sinners, that it was their right
and duty to make war upon them wherever they could be found, and to
make slaves of all they could take as Prisoners, and that every
Musselman (Muslim) who should be slain in Battle was sure to go to
Paradise." 
For the following 15 years, the American government paid the
Muslims millions of dollars for the safe passage of American ships
or the return of American hostages. The payments in ransom and
tribute amounted to 20 percent of United States government annual
revenues in 1800.
Not long after Jefferson's inauguration as president in 1801, he
dispatched a group of frigates to defend American interests in the
Mediterranean, and informed Congress.
Declaring that America was going to spend "millions for
defense but not one cent for tribute," Jefferson pressed the issue
by deploying American Marines and many of America's best warships
to the Muslim Barbary Coast.
The USS Constitution, USS Constellation, USS Philadelphia, USS
Chesapeake, USS Argus, USS Syren and USS Intrepid all saw
action.
In 1805, American Marines marched across the desert from Egypt into
Tripolitania, forcing the surrender of Tripoli and the freeing of
all American slaves.
During the Jefferson administration, the Muslim Barbary States,
crumbling as a result of intense American naval bombardment and on
shore raids by Marines, finally officially agreed to abandon
slavery and piracy.
Jefferson's victory over the Muslims lives on today in the Marine
Hymn, with the line, "From the halls of Montezuma, to the shores of
Tripoli, We fight our country's battles in the air, on land and
sea."
It wasn't until 1815 that the problem was fully settled by the
total defeat of all the Muslim slave trading pirates.
Jefferson had been right. The "medium of war" was the only way to
put and end to the Muslim problem. He was a "visionary" wise enough
to read and learn about the enemy from their own Muslim book of
jihad.