Israel sent gunboats to shell northern Lebanon and postponed a high-level visit to Cairo today in swift response to a Palestinian terrorist attack during the night that left four Israelis dead in the coastal city of Nahariya.

But Israel Foreign Minister Moshe Dayan, while describing the raiders as "barbaric murderes," said the Palestinian attacks "will not destroy the peace treaty between Israel and Egypt."

The raid, in which a four-man squad of Palestinians landed in a rubber boat and blasted their way into an apartment building, was the bloodiest here since Palestinian guerrilas stepped up their activities to protest the Egyptian-israeli peace treaty.

Among the victims were a young father and his 4-year-old daughter, who were taken hostage and then shot to death as security forces closed in on the guerrillas on the beach where they had landed. Another daughter, 2 yearsold, was killed in the apartment and an Israel policeman died in a gun battle with the terrorists.

Two of the four-man squad were killed, one as he tried to shoot his way into another apartment and another while trying to make his escape. Two others were wounded, along with four Israeli civilians.

In Beirut, the Iraqi-backed Palestine Liberation Front claimed responsibility for the attack, which occurred shortly before 3 a.m. Reports from Beirut said the Palestine Liberation Organization, the umbrella guerrilla grouping for most commandos, ordered a maximum alert in anticipation of a retaliatory strike by Israel.

The israeli government announced tonight that naval ships shelled what the government said was a terrorist base of the Popular Front of the Liberation of Palestine near the Nahar al-Bared refugee camp, north of Tripoli, Lebanon.

A PFLP spokesman in Beirut said the Israelis fired on the camp itself, destroying three homes and "wounding 10 women and children."

The Israeli government said it struck the Popular Front, led by George Habash, because it is "predominant of the organizations of the rejectionist front (land) is already responsible for dozens of cases of the murder of civilians."

The Popular Front and the Palestine LiberationFront both belong to the so-called rejectionist front, which refuses the idea of settling the dispute with Israel peacefully and disagrees with Yasser Arafat's overall Palestine Liberation Organization.

Earlier, the Israel Cabinet reacted with outrage at the Nahariya attack. Dayan called it "sheer assassination, sheer murder."

Speaking to an international meeting of publishers, Dayan said, "I cannot imagine any representative of Israel sitting down with these people...after such an incident. They proudly announce they are responsible."

Noting that Arafat had publicly pledged to "set fire" to the Middle East, Dayan said: "They will not set fire to the Middle East. They can kill three, or five or 10 civilians, but that will not turn the Middle East into fire, and they will not destroy the peace treaty between Israel and Egypt."

Because of the attack, however, Defense Minister Ezer Weizman and Army Chief of Staff Gen. Rafael Eitan postponed a trip to Cairo, scheduled for today, in which they were to have discussed with their Egyptian counterparts technical aspects of Israeli withdrawal from the Sinai Peninsula.

As Weizman and Eitan flew to Nahariya, Prime Minister Menachem Begin telephoned Egyptian President Anwar Sadat to expain the postponement. The two leaders agreed that it would not delay Wednesday's scheduled ceremonial exchange of the treaty ratification documents at a U.S.-manned listening post in the Sinai buffer zone.

Begin's office said Sadat "accepted with complete understanding the decision... and expressed his sympathies for the losses caused to Israel by the terrorism in Nahariya."

Weizman and Eitan are expected to make the Cairo trip after independence day observances in Israel next month.

Israeli Army officicals said the four terrorists set out from Tyre, the coastal PLO stronghold in southern Lebanon, in a rubber dinghy powered by an outboard motor and landed in Nahariya, a resort town of 30,000 about seven miles south of the Lebanses border.

Authorities said the guerrillas rang a lobby intercom in an apartment building, but that the tenant became suspicious of their broken English and called police. When the police arrived, a gunbattle erupted and a 24-year-old police sergeant, Aliahu Shachar, was killed.

The terrorists then stormed an apartment and took Danny Harran, 28, and his 4-year-old daughter, Annette, hostage after killing a second daughter, Yarl, 2, according to an Israeli Army spookesman.

[The Associated Press quoted neighbors of the Harans as saying the 2-year-old girl was accidentally suffocated by her mother. who was trying to keep her quiet as they hid from the terrorists.]

One of the terrorists tried to break into another apartment, but was shot by Charles Shapiro, 34, an immigrant from South Africa who said the terrorists were shooting randomly through doors.

Shapiro said he heard Haran pleading with the terrorists to take only him, and leave his daughters behind.

Shapiro grabbed a 22-caliber magnum revolver and stood out of the line of fire until one terrorist burst through the door.

"That's when I came out from the pillar I was hiding behind and shot him in the chest . . . He was still alive, of course, and he had an automatic (rifle) in his hand, so I shot him through the head," Shapiro told Radio Israel.

witnesses said that as the terrorists fled with the hostages, they hurled hand grendaes behind them.

Officials said that on the way back to their boat. the terrorists were confronted by an Army patrol, and that the hostages were shot immediately. One of the guerrillas was killed in the ensuing gun battle and two were wounded.

The attack marked the third time in a week that terrorist squads penetrated Israel overland or by sea, although in two previous incidents Army patrols surprised the guerrillas and wiped them out. Since the first of the year, 19 terrorists have been killed while infiltrating into Israel.

Security officials said that seaborne attacks are the most difficult to prevent because of the miles of desolate beaches along the Mediterranean coast.

In the numerous retaliatory attacks in Lebanon, Israeli warplanes have frequently hit small PLO marinas from which the boat attacks have been launched. The bloody March 1978 terrorist attack on a tourist bus near Tel Aviv was made from rubber boats, leading to the Israeli invasion of Lebanon several days later. CAPTION: Map, no caption; By Dave Cook-The Washington Post Picture, The four Palestinians who attacked an Israeli town join hands in photo distributed by their organization. AP