Jimmy Carter is not the first American president to be faced with a hostage crisis in the Islamic world. Washington, Adams, Jefferson and Madison were repeatedly plagued with just that problem. It was Jefferson and his secretary of state and successor, Madison, who came up with a solution.

At the time, there were, on the Barbary Coast of North Africa, four Islamic kingdoms -- Morocco, Algeria, Tunisia and Tripoli -- that lived mainly by stealing on the high seas. Rather than prevent such outrages, the maritime nations of Europe avoided depredations by paying formal bribes or "tribute."

The United States, under Washington and Adams, followed the European example. Through the Washington administration built a small navy in response to Arabic threats, it opted, under popular pressure, to mothball the fleet and pay tribute instead.

Jefferson and Madison refused to follow such a course. Jefferson sent the infant U.S. Navy to the Mediterranean to engage in defensive operations, protecting American merchant ships.

The hostage crisis came in 1803. Late that year, the 44-gun frigate USS Philadelphia ran aground on a sand bar off Tripoli, and its entire crew was taken hostage. That was a routine instrument of statecraft in the Islamic world; when European governments proved loath to pay tribute, Barbary Coast rulers whipped them into line by seizing their nationals and holding them in dungeons until they capitulated and, incidentally, ransoms were paid.

Jefferson would have no part of it. He threw the entire U.S. Navy, such as it was, against Tripoli -- not to free the hostages, but to teach the Tripolitans never to trifle with the United States agan. After some spectacular fighting, the pasha of Tripoli was forced to agree to cease plundering American ships and to waive American tribute in future. The captives were released, unharmed.

But the American commander, Edward Preble, was not content to let the matter rest there. Interpreting the president's orders liberally (and properly), he gave the Algerians and the Moroccans a taste of the same medicine. The Jefferson administration was then able to establish a general settlement on favorable terms.

Unfortunately, during the War of 1812, the Algerians took advantage of America's troubles and resumed their raiding. Nearly 200 American merchant seamen were captured, imprisoned and forced into slavery. As soon as it became possible, the Navy was sent out to tend to the matter.

In 1815, Madison dispatched Capt. Stephen Decatur to the Mediterranean with three frigates, two sloops of war and five light Baltimore clipper-schooners. Just past the Strait of Gibraltar, the squadron sighted the Algerian flagship and reduced her to garbage in 20 minutes.

Decatur sailed on to Algeria and paid the pasha a personal call. Not only must the piracy stop, tribute to be forever ended and the enslaved crews released, Decatur said, but the pasha must pay the United States an indemnity for having captured the crewmen in the first place.

The pasha demurred, whereupon Decatur calmly informed him that the Americans would start sinking Algerian ships, one by one, until either the money was paid or there was not so much as an Algerian rowboat left afloat. The pasha capitulated. The Decatur did the same thing with the rulers of Tunis and Tripoli, with the same results.

The Barbary rulers were a shippery lot and no doubt planned to go back to their old ways as soon as Decatur was out of sight. But they were in for a rude surprise. Decatur had scarcely sailed out before an American squadron under William Bainbridge sailed in to pay a polite "social call." The rulers got the message.

To make sure they did not forget it, the Navy leased a permanent base at Port Mahon on the island of Majorca and cruised the Mediterranean on "friendly" visits for years thereafter. The Barbary Arabs did not forget.