Lebanon and Israel formally signed peace accords today that hold the promise of securing the withdrawal of occupying Israeli soldiers and of strengthening relations between the neighboring countries.

With U.S. Middle East envoy Morris Draper as witness, the agreements were signed in back-to-back ceremonies in Lebanon and Israel. Residents of this tense, war-battered capital braced for expected Syrian-inspired reprisal attacks, while schoolgirls handed flowers to the top negotiators in an Israeli border town that once was bombarded by Palestinian artillery based in southern Lebanon.

The hitch in the agreement is whether Syria ultimately will go along, an uncertainty that cast a somber shadow over today's events.

Top Israeli negotiator David Kimche reaffirmed that Israel will not withdraw its troops under the accord until Syrian and Palestinian forces also leave Lebanon.

Syria in recent days has threatened unspecified dire consequences if Lebanon signed the accords, but Beirut residents allowed themselves to breathe a bit more easily this evening after there had been no outburst of fighting as feared. Syria's immediate protest appeared to have taken the form of disrupting traffic and communications lines in areas that it occupies in northern and eastern Lebanon.

Syria accused the Lebanese government of betraying the Arab cause by signing the accords. A commentary in the ruling Baath Party's newspaper said this morning that Lebanese President Amin Gemayel's government, by assenting to the agreement, "has lost its legitimacy, as well as its capability and competence in directing the Lebanese people and becomes a full partner of Israel and the United States in their schemes against the Arab world."

The newspaper said Syria would block implementation of the accords "for the sake of the security of Lebanon and Syria," adding, "we have numerous and diversified means to do so."

In Israel, Defense Minister Moshe Arens said that if Syria refuses to withdraw from Lebanon, Israel would consider a partial pullback of its troops in consultation with Beirut and Washington, Reuter reported.

Interviewed on Israeli Army radio, Arens said that a pullback coordinated with Lebanon and the United States would prevent Palestinian guerrillas and Syrian troops from taking up positions evacuated by Israel.

The day's ceremonies began at Khaldah, in one of the bomb-ravaged beachfront hotels on a desolate strip in the outskirts of Beirut, where gaping holes and pockmarks of the artillery fired during the Israeli siege last summer are still visible. The five-month negotiations, concluded after a personal shuttle mission by Secretary of State George P. Shultz, took place in Khaldah and in the Israeli border town of Qiryat Shemona.

"Events have taught us that our country, however beautiful, however beloved, is not an absolute but an earthly creation liable to be destroyed," said Lebanese chief negotiator Antoine Fattal, referring to the past eight years of civil war and foreign occupation in Lebanon.

In Qiryat Shemona in the Galilee, where the second set of ceremonies was held, there was celebration and gaiety including the singsong of children outside.

Israeli negotiator Kimche, director general of the Israeli Foreign Ministry, said the plain hillside town of garden apartments with its throngs of children "knows, more than all of us, why we were forced to enter Lebanon nearly a year ago: in order to do away with, once and for all, the constant danger to the Galilee."

Bomb shelters to guard against the rain of artillery that the PLO once had fired into the town from Lebanon are still standing.

Israelis celebrated the accords as the first step toward a full-blown peace treaty with Lebanon, which would be Israel's second with an Arab country. The agreement creates a quasi-embassy in the form of a liaison office in Lebanon. Its Israeli representatives would be granted "limited immunity" instead of "diplomatic immunity." It provides for limited trade and movement of people across borders and, after a six-month interim period, talks on more normal relations.

In his speech in Lebanon today, Israel's Kimche referred to the Old Testament, mentioning the reports there of the good relations between the ancient Israelites and King Hiram of Tyre in present-day Lebanon. Kimche quoted a passage in the Book of Kings, which says "there was peace between Hiram and Israeli King Solomon, and the two made a treaty."

For the Lebanese, talk of a peace treaty was ruled out firmly. Such a pact would exacerbate their problems with Syria and jeopardize their standing among the Arabs, who are important to their trade.

"The agreement we are signing today is not a peace agreement," Lebanon's Fattal said. "It is a step toward a just and lasting peace. I borrowed that expression from the disengagement agreement made on May 31, 1974, between Syria and Israel."

Answering Syrian criticisms, Fattal added, "Lebanon intends to remain faithful to its Arab vocation, in spite of its hazards, while ending the state of war with Israel."

Today, Syria's response appears to have been limited to blocking travelers and trade on the vital overland route from Lebanon to Syria and hence to the Persian Gulf. If continued for a long time, such a blockade could have devastating effects on Lebanon's economy.

Yet the Syrian steps were far less than the Lebanese had expected. Anticipating renewed shelling of Beirut, possibly by Syrian-allied Moslem Druze militiamen in the hills overlooking the capital, many schools here were closed and hoarders lined up at gas stations and grocery stores as during last summer's long Israeli siege.

There was one difference this time. Persons seeking security moved from Christian East Beirut, a safe zone during the Israeli siege because of Israel's relations with Christian leaders, to predominantly Moslem West Beirut, which is thought now to be more secure from Syrian attack.

The strong Syrian opposition to the accords was offset to some extent by guarded support from Saudi Arabia, a chief financial backer of both Syria and Lebanon, The Associated Press reported.

Saudi Information Minister Ali Shaer said in a carefully worded statement: "The kingdom, expressing respect for the free will of the Lebanese people as manifested through their constitutional establishments to practice the right to regain sovereignty and spread their authority over their entire territory, wishes to affirm the necessity of immediate Israeli troop withdrawal from all territory, along with completely safeguarding Lebanon's independence, Arab nature, security and stability."

Reuter added the following:

Five people died today in two separate incidents in Lebanon.

In the northern city of Tripoli, which lies within territory controlled by the Syrians, four people died in an armed clash involving Palestinian fighters and local Moslem militias, local residents said.

Earlier, one person died and 10 were wounded in a clash in a Beirut suburb between the Lebanese Army and Shiite Moslems protesting the withdrawal accord, official sources said.