Lebanese officials today declared the long and difficult negotiations for an agreement for the peaceful evacuation of Palestinian guerrillas from West Beirut to be virtually at an end.

The U.S. contingent of an international force to monitor the evacuation was already at sea in the Mediterranean on its way to the embattled Lebanese capital.

There were conflicting reports, however, on whether the accord mediated during the past two months by U.S. special envoy Philip C. Habib would be wrapped up in time for final approval at a Lebanese Cabinet meeting scheduled for Wednesday.

Israeli officials said they believed only "technical issues" were delaying completion of the final withdrawal plan, Washington Post correspondent Edward Walsh reported from Jerusalem. But they also warned that they would hold Syria responsible for any PLO attacks from Syrian-controlled territory after the evacuation. Details on Page A17.

In Washington, U.S. officials expressed the hope and expectation that a final agreement could be concluded Wednesday.

After Habib held another session with Lebanese government leaders at the palace of President Elias Sarkis at Baabda in the hills above the capital, Prime Minister Shafiq Wazzan told reporters that he expected to be able to announce details of the final plan Wednesday.

"We have reached the end of our sorrows," Wazzan said, "at least on paper." He said implementation of the Habib plan will begin after Wednesday's Cabinet meeting.

But that optimistic assessment was tempered somewhat tonight by former Lebanese prime minister Saeb Salam, Habib's intermediary with the Palestine Liberation Organization. Salam said there were at least two issues still pending, although he was hopeful that they would be resolved soon.

"The negotiations are at the very end," Salam said after meeting with Habib. "In a few days they will be resolved." When questioned, he did not rule out the possibility that an agreement might be reached by Wednesday, but he indicated that he thought it could take a bit longer.

Under the plan, an official Lebanese request for the landing of an international force of 2,000 troops from the United States, France and Italy cannot be made until the final accord is ratified by the PLO, the Lebanese government and the Israeli Cabinet.

A contingent of U.S. Marines was steaming toward Lebanon from the Italian port of Naples to participate in the peace-keeping force. About 350 French paratroopers, expected to be the vanguard of the force, and a battalion of more than 500 Italian infantrymen were on alert in their bases and ready to put to sea.

Until the landing of the force is officially approved, however, the evacuation of the reported 7,100 PLO guerrillas and another 5,000 Palestinian and Syrian soldiers under Syrian military authority cannot start. The evacuation is to begin simultaneously with the arrival of the first contingent of the international force.

Israeli Defense Minister Ariel Sharon, architect of Israel's 66-day siege of West Beirut, met with Habib today at the residence of the U.S. ambassador near Baabda to demand that Habib get fresh guarantees from Syria that it will withdraw its troops from Beirut.

"In my estimate, we will have a clearer picture within 24 hours," United Press International quoted Sharon as telling Israel's Armed Forces Radio.

"We are very close to a solution," Sharon said, but he added that "there is need for further clarifications."

According to reliable sources close to the Habib talks, the Syrians last week told Gen. Sami Khatib, the titular Lebanese commander of the Arab peace-keeping force, that they would withdraw their troops along with those of the PLO if asked to do so by the Lebanese government.

But more ambiguous official statements about the withdrawal quoted by Syrian radio over the weekend apparently prompted Sharon to demand that Habib get a specific guarantee from Syrian President Hafez Assad.

Salam said another unresolved issue was the means by which the Lebanese authorities, aided by members of the international monitoring force, would keep a count of the departing guerrillas. Some are expected to leave Beirut by sea, while others will travel overland to Damascus, from where they will be dispersed to eight Arab countries that have agreed to receive them.

Israel originally demanded the names, ranks, and identity card numbers of all the evacuated guerrillas. But after the PLO refused to provide anything more than numbers and destinations of the groups, Israel eased its conditions earlier this week. Lebanese sources said Israel still wanted some way of verifying that all those who are supposed to leave actually do.

The final issue holding up the agreement was Israel's demand that the PLO free Lt. Aharon Ahiaz, the organization's lone prisoner of war, and turn over the remains of nine Israeli soldiers -- five killed in the invasion of Lebanon that began June 6 and four killed in the 1978 Israeli invasion of southern Lebanon.

The PLO has suggested that an exchange of prisoners be negotiated through the International Red Cross and that Israel agree to free an undetermined number of guerrillas from the 7,000 it reportedly holds.

As final approval of Habib's peace plan hung in the balance tonight, Lebanon's political leaders turned their attentions to the election of a new president.

Sarkis' term expires Sept. 23, and the speaker of the Lebanese parliament has called for deputies to convene Thursday to elect a successor. The suddenly scheduled election has thrown Lebanese politicians into a flurry of meetings, consultations and back-room political negotiations.

Moslem politicians in West Beirut, as well as some Christians in the east, are opposed to holding the election while Israeli forces occupy half the country. They contend that Israel is trying to use its power to ram through the parliament the election of its longstanding ally, Bashir Gemayel, leader of the Christian Phalangist militia. To date, he is the only declared candidate.

Gemayel's election is unacceptable to many Moslem politicians who remember his violent leadership of the Christian militia in the 1975-76 civil war.

Even many politicians from rival Christian factions are opposed to Gemayel's becoming the next president.

"If Bashir is elected, all the bloodshed that we have seen so far could prove to be just a rehearsal for the future," said one Christian Cabinet minister today, who insisted that his name not be used out of fear of retribution.

Salam indicated tonight that he and fellow Moslems were determined to stay away from parliament Thursday to block a quorum. This would force the postponement of the election, giving all of Lebanon's political leaders more time to reach a consensus.

Although it appeared that the election would not be held Thursday, Israel today went ahead with plans to facilitate the polling by beginning a withdrawal of its forces from the parliament building, which lies on the rubble-strewn Green Line separating Beirut's Moslem western sector from the Christian east.

After withdrawing tanks from around the building, which had been used to fire on PLO positions across the Green Line, the Israeli military commander of the sector turned over his command of the building to Col. Michel Aboun of the Lebanese Army. It was the first Israeli withdrawal from any positions around battered West Beirut.

Between meetings with Habib today, Sarkis conferred with several of Lebanon's traditional power-brokers. Sources said the suggestion was again raised that, in view of the continuing uncertainties, Sarkis consider having his term of office extended, a suggestion he has repeatedly rejected in the past.