Lebanese President Amin Gemayel met secretly last week with a top aide to Palestine Liberation Organization Chairman Yasser Arafat to initiate what is likely to be a long and difficult dialogue over the future of Palestinians in Lebanon, according to reliable sources here close to the PLO leadership.

The meeting between Gemayel and the PLO's Salah Khalaf, a key Arafat deputy also known as Abu Iyad, was to prepare for direct talks later between Arafat and Gemayel about the continued presence of the PLO in Lebanon and the organization's concern for the safety and welfare of the half million Palestinian civilians still there.

PLO sources in Tunis, where Arafat now has his headquarters, confirmed that the meeting, arranged by King Hassan, took place in Morocco on Nov. 1 during Gemayel's one-day trip to the North African kingdom. It was Gemayel's first visit to an Arab nation since taking office Sept. 23. The sources were reluctant to discuss details of the talks.

But senior PLO officials interviewed in Damascus, Syria, and here during the past two weeks have made it clear that before there can be any thought of the evacuation of PLO military units from northern and eastern Lebanon -- as Israel has demanded as a condition for its own withdrawal from Lebanon -- the PLO expects a negotiated accord with Gemayel's government that would put relations with the PLO on an official basis and provide for its continuing political and military presence in Lebanon.

The PLO's demand for what amounts to a revision of the Cairo accords of 1979, which first established its legal right to maintain military bases in southern Lebanon, could prove to be a major obstacle to the efforts of U.S. envoy Morris Draper to negotiate a withdrawal of all foreign troops from the country: Palestinian, Syrian and Israeli.

Israel used the PLO's presence in southern Lebanon as a justification of its June 6 invasion.

Israel has demanded that the remaining forces of the PLO in Lebanon must be the first foreign forces to be withdrawn. Since the PLO's evacuation from Beirut in August, its forces have been massed around the northern port city of Tripoli and the eastern Bekaa Valley, where the Syrian Army is dominant.

Once the Palestinians have withdrawn, Israeli officials have indicated, Israel would be prepared to agree to a "simultaneous" Israeli and Syrian withdrawal if Jerusalem was also guaranteed a 30-mile-deep security zone in southern Lebanon to keep any Arab military forces from Israel's northern borders.

But PLO leaders, like their Syrian allies, insist that their prior official agreements with past Lebanese governments regulating their military presences in Lebanon give both the PLO and Syria a legal justification for being in Lebanon that the Israelis, who are there by virtue of their invasion, do not possess.

The PLO bases that claim on the Cairo agreements negotiated between the PLO and the Lebanese government under the aegis of the late Egyptian president Gamal Abdel Nasser.

The Syrians maintain that their forces have equal legal status in Lebanon, having come there at the behest of the country's legitimate government in 1976 under a peace-keeping mandate from the Arab League to end Lebanon's civil war.

In recent weeks, as Draper has renewed his mediation efforts in Beirut, Jerusalem and Damascus, both Syrian and PLO leaders have emphasized that they were not prepared to consider pulling out of Lebanon unless Israel withdrew first.

"Our stand is that if there is a mutually agreed withdrawal of Israeli and Syrian forces, we will then be prepared to discuss everything, including our military presence, with the Lebanese president," said Khalil Wazir, the PLO's equivalent of a defense minister who is better known as Abu Jihad, his nom de guerre.

Wazir, one of Arafat's top lieutenants, made clear, however, that in view of the massacre of Palestinian civilians by Israeli-supported Lebanese Christian militiamen in two Beirut refugee camps in September, the PLO would not pull out of Lebanon any farther until a new agreement with Lebanon was established that would preserve the PLO political and military presence in the country as well as provide ironclad guarantees for the half million Palestinian civilians living there.

"The PLO is prepared to accept the Lebanese nation's independence and unity," Wazir said, "but we hope that the Lebanese government will take into consideration the question of guaranteeing the ordinary life and safety of our Palestinian civilians."

Wazir said that the PLO expected a new accord to include guarantees for the security of Palestinians in Lebanon and the modalities under which the PLO would be allowed to continue its welfare services to its people in the country, its political presence in Beirut, and continued presence of PLO military units in Lebanon, perhaps attached to the Lebanese Army as they are attached to other national armies.

Wazir said he hoped that these concerns would be discussed soon between Arafat and Gemayel. Khalaf's meeting with the Lebanese president in Morocco, PLO sources indicated, was to prepare the ground for such a discussion, perhaps when Gemayel visits other Arab capitals in the coming months.

At present, the PLO is reported by Western intelligence agencies to have from 6,000 to 10,000 fighters in Lebanon. The Syrian Army, still in the form of the Arab League's Arab Deterrent Force, is reported to have from 30,000 to 39,000 troops in the country, mostly dug into defensive positions in the Bekaa Valley. The Israeli Army, which has been thinned out considerably from an estimated height of 100,000 men during the invasion last summer, is believed to have between 40,000 and 50,000 men in Lebanon.