They considered us infidels -- and easy targets. They committed atrocious acts against civilians. They provoked war with America.

"They are odious for the constant violation of the laws of nations and humanity," as one writer put it. We saw them as bloodthirsty fanatics, sanctioned by Islamic despots, and we believed their behavior threatened the future of the modern world.

Thus the president found it necessary to launch America's first military campaign against state-sponsored terrorists. Except he didn't call them that, because 200 years ago, everyone called terrorists by another name: pirates.

For all the talk in Washington that the current battle against global terrorism represents an entirely new kind of war, against a different kind of enemy, historians say America's seen this before. Back when the nation was largely untested in the arena of foreign entanglement, we found ourselves in an extended, exasperating campaign against various Muslim states in North Africa, which harbored the notorious Barbary pirates. By most reckonings, that battle lasted 30 years.

"I've picked up a lot of parallels," says Capt. Glenn Voelz, a history instructor at West Point. "Maybe we are still fighting the same war. It's a worthwhile question for my students to consider: What's changed in 200 years between Jefferson's administration and Bush's administration?"

For one thing, although the Barbary pirates were good at instilling terror -- using cannons and scimitars -- they were not waging a holy war against Americans. They were opportunists, historians say. They first declared war against us in 1785 -- when Algeria seized two American vessels off Portugal, imprisoning 21 people -- and goaded us into combat again in 1801 and 1815.

They considered themselves "privateers," authorized to confiscate ships and crews just as other feuding countries did. Their enemy? Any nation that hadn't negotiated peace treaties with their rulers in Tunis, Tripoli, Algiers and Morocco. For centuries their pirates shook down European nations for ransom and tribute money.

"This was a protection racket," notes Richard B. Parker, former U.S. ambassador to Algeria, Lebanon and Morocco, who is writing a history titled "Uncle Sam in Barbary." "They didn't have political objectives, they just wanted money."

The banditry was rooted, however, in centuries of religious strife between Muslims and Christians. The pirates, nominally subject to the Ottoman sultan, were still battling the descendants of the Crusaders. (In 1605, St. Vincent de Paul was among those kidnapped by the Barbary pirates and sold into slavery to Muslims.) Captured Christians could gain freedom by "taking the turban" or "turning Turk" -- that is, by converting to Islam.

Then, as now, Americans were baffled by those who held militant Islamic beliefs and imposed theocratic rule. Then, as now, our military had to innovate and our statesmen had to scramble to address a new threat to national security.

"Would to Heaven we had a navy to reform those enemies to mankind, or crush them into non-existence," Gen. Washington wrote in 1786. The nation built that navy largely because the pirates' hostage-taking and escalating ransom demands became politically unbearable.

Then, as now, we viewed the enemy as primitive demons incarnate. An American captive reporting to his countrymen in 1798 declared the enemy "more like monsters than human beings." David Humphreys, in his "Poem on the Future Glory of the United States of America," railed against:

Audacious miscreants, fierce, yet feeble band

Who, impious, dare

Insult the rights of man.

Facing a criminal menace abroad, Americans reaffirmed their commitment to democratic ideals at home. Talk of "national character" flourished. The Constitution was ratified. The pirate crisis, historians say, made America grow up.

"There's a temptation to view all of our problems as unprecedented and all of our threats as new and novel," says George Washington University law professor Jonathan Turley. Shortly after the terror attacks of Sept. 11, Turley advised some members of Congress who were considering a formal declaration of war against the suspected perpetrators. He invoked the precedent of the Barbary pirates, saying America had every right to attack and destroy the terrorist leadership without declaring war.

"Congress did not actually declare war on the pirates," Turley wrote in a memo, "but 'authorized' the use of force against the regencies after our bribes and ransoms were having no effect. This may have been due to an appreciation that a declaration of war on such petty tyrants would have elevated their status. Accordingly, they were treated as pirates and, after a disgraceful period of accommodation, we hunted them down as pirates."

Because of their outlaw conduct, pirates -- and modern-day terrorists -- put themselves outside protection of the law, according to military strategy expert Dave McIntyre, a former dean at the National War College. "On the high seas if you saw a pirate, you sank the bastard," he says. "You assault pirates, you don't arrest pirates."

Shoot first, ask questions later. Wanted: Dead or alive. Such is our official policy regarding Osama bin Laden, the most infamous outlaw of the era.

One of the enduring lessons of the Barbary campaigns was to never give in to outlaws, whether you call them pirates or terrorists. In the late 1700s, America paid significant blackmail for peace -- shelling out $990,000 to the Algerians alone at a time when national revenues totaled just $7 million.

"Too many concessions have been made to Algiers," U.S. consul William Eaton wrote to the Secretary of State in 1799. "There is but one language which can be held to these people, and this is terror."

On the home front, meanwhile, Americans feared infiltration by murderous pirates. Historian Voelz cites passage of an act in the Virginia assembly empowering the governor to expel "suspicious aliens" in case of hostilities with their sovereigns. "This case apparently developed after the arrival of two or three [Algerians] in Richmond," Voelz wrote in his master's thesis.

The protection money demanded by the "nests of banditti" (as the Founding Fathers called them) continued to escalate. In 1801 the pasha of Tripoli declared war on the United States because we refused to pay him higher tribute than we paid the Dey of Algiers. While Congress was out of session, President Jefferson deployed gunboats to the Mediterranean, and a new phase of the Barbary wars was on.

Lawmakers proclaimed their support, and the public rallied behind the slogan, "Millions for defense, but not one cent for tribute!" Legends and heroes were created as American troops ventured "to the shores of Tripoli," as the Marine Corps Hymn would later put it.

Voelz sees "striking parallels" between the U.S. excursion into Tripoli and the situation unfolding in Afghanistan, where American forces are working to destabilize the ruling Taliban without inflaming the Islamic world. In 1805, the United States mounted a special operation against the Tripolitan regime -- buying, supplying and otherwise building an army of Arab insurgents to mount an attack on the pasha.

It was no beach landing. The small group of Marines immortalized in song actually traveled 520 miles across the desert from Alexandria, Egypt, to reach the harbor at Derna. They captured the fort and raised the Stars and Stripes, but ultimately were unable to install a more malleable pasha.

In calling on Muslims for support, Eaton, as a U.S. naval agent and the operation's leader, denounced "cruel and savage" despots who oppressed their own people -- and defiled the true teachings of Islam (Eaton had studied the Koran):

"Our religion teaches us to fear and worship God and to be kind to all his creatures . . . Be assured that the God of the Americans and of the Mohometans [Muslims] is the same; the one true and omnipotent God."

The Tripolitan War ended in 1805, but outlaw elements continued to make trouble. "We were taught, in the schoolbooks, that the United States in its first real war had cowed the dastardly Barbary princes," wrote Donald Barr Chidsey in his book "The Wars in Barbary." "This was not so."

Ten years later, another war on America was declared -- by the Algerians again. Congress authorized an expedition, and a fleet commanded by Navy hero Stephen Decatur successfully attacked Algiers. In 1815, the Dey of Algiers released all American captives and stopped demanding tribute.

But the pirates kept preying on European ships until France captured Algiers in 1830. Author C.S. Forester, in a popular book for young readers titled "The Barbary Pirates," tried to explain why the outlaws kept at it for so long.

"The pirates must have war," said Forester. "Otherwise, the world would soon cease to fear them."

A U.S. squadron bombards forts of the Barbary pirates at Tripoli in 1804.Naval hero Stephen Decatur, shown in a copy of a Gilbert Stuart painting, made the Dey of Algiers free captives and forgo tribute.