On a low bluff above the shores of Tripoli's harbor is a small walled compound where five American military men rest in little, white, coffin-shaped tombs beneath identical gray marble plaques. No crosses. No names. Just the legend:

"Here lies an American sailor who gave his life in the explosion of the United States ship Intrepid in Tripoli Harbor Sept. 4, 1804."

Now each day and night as guns and rockets erupt from shore batteries nearby, firing at American attacks both real and imagined, the cemetery itself is on the front lines.

But when the guns die down, this graveyard behind crumbling stucco walls topped with broken glass is, like the rest of Tripoli, weirdly peaceful. The only noise is that of the wind tousling the upper branches of an ancient olive tree at the cemetery's center.

The graves are reminders of the long history of American involvement here.

In 1799, Americans were paying annual tribute to Tripoli's pirates to allow their ships safe passage in the Mediterranean. But in 1801 the local ruler upped the ante to the then phenomenal amount of $250,000 a year. Not to pay would mean American ships and travelers constantly facing death or capture for ransom by his boarding parties.

President Jefferson responded with force. After a commando attack by U.S. Marines, a small invasion from Egypt, naval bombardments and political subversion against its ruler, Tripoli negotiated a peace that lasted until Muammar Qaddafi took power and began to project his ambitions in the 1970s.

One of his earliest acts was to expel the Americans and close their enormous strategic Wheelus Air Base. It reopened as a Libyan installation, which was bombed early Tuesday.

Americans remember the 1804 commando raid to blow up the stranded U.S. ship Philadelphia as a triumph celebrated in the Marine hymn. The ship's guns, which had been turned against the Americans, were destroyed.

Libya claims the whole affair as a victory. Qaddafi often refers to it as a warning to Washington, a lesson from history. Other officials talk of it almost as if it were yesterday.

"The Philadelphia soldiers were arrested," said one Information Ministry functionary. "So they [the Americans] sent suicide squads and blew it up."

The American sailors captured on the Philadelphia were held, in fact, as hostages. They were forced to work on Tripoli's defenses against Jefferson's fleet.

Now that something very much like war has begun here again, Washington must be concerned with the old Libyan tradition of holding its enemies for ransom, though this time the price may be more political than pecuniary.

Diplomats and oil company officials estimate that there are now between 600 and 800 Americans here. There are 10 times that many Italians and about 5,000 Britons.

When the confrontation with Qaddafi began building more than four years ago, the Reagan administration ordered all Americans to leave the country. In January, Washington threatened legal action against those who disobeyed, and many left by the Feb. 1 deadline.

But other Americans remained or came back once exit visas had been stamped onto their passports.

Now that shooting has started, Reagan administration officials have said the U.S. citizens here were warned, and that apparently is that.

American reporters here have thus far been unable to contact any of their compatriots since the air raids. But there appears to be no evacuation plan for them and, for the time being, there may be no need. In his television speech last night, Qaddafi once again expressed his desire that foreigners here not be molested, and this morning American reporters encountered no real hostility on the streets.

Walking along the corniche above the naval base on my way to the cemetery, I had no problems except with officials responsible for my safety who stopped me and asked me to return to the hotel in case shooting began again.

The cemetery was closed. Suleiman Sadiq, who has tended the tombs for the last 24 years, had stayed home along with most of the capital's population.

Sadiq, when I had talked to him before, called the graveyard, no bigger than a Cleveland Park backyard, "the English cemetery." But its graves are an international gathering: Dutch and Swedish and Danish as well as British but, as much as any, American.

There are the graves of families drowned in shipwrecks. There are the little tombs of babies. An American consul had two sons born here in the 1830s. Neither lived to the age of 2.

Sadiq does not pay much attention to these. They are "broken," he said. Only the stones of the five American sailors continue to be maintained, casualties in one of America's first assertions of international power. Their last full restoration was done in 1953, says a plaque outside, by the Wheelus Field Officers Wives Club.