Leading Lebanese politicians yesterday agreed on a broad-based formula optimists hoped would end the divisions that in recent years have made Lebanon synonymous with anarchy, chaos and violence.

Political analysts, however, described the agreement as only an encouraging first step in what remains a still rocky road to restoring political stability to the much-battered Lebanese state.

The agreement's key provisions called for an end to armed Palestinian "action" in Lebanon and a similar prohibition of mostly Christian, "illegal, armed" militias.

The first result of the deal, analysts said, was expected to be a decision by President Elias Sarkis to renominate Selim Hoss as premier. Hoss resigned Wednesday with his eight-member Cabinet of technicians.

Whether Hoss will be able to stitch together a politicians' Cabinet - and how long that might take - remained unclear. The inability to do so could prove fatal to the calculated risk Sarkis and Hoss took in agreeing to have the government resign.

The new agreement was to be carried out in keeping with the Cairo and Riyadh summits which formally ended the 19-month Lebanese civil war in October 1976.

Their provisions calling for disarming the various belligerents have not been respected.

A buoyant atmosphere prevailed among the 13-member parliamentary committee that drafted the agreement. In contrast was the ominous absence of statements from the Palestinian guerrilla movement or its allies on the left, who have opposed the government of moderate Moslem and right-wing Christian elements.

Even within the right-wing Christian Phalangist Party, its nominal leader Pierre Gemayel's praise for the accord as "a supreme victory" contrasted with the tough talk by his son Beshir, overall commander of the Christian militias. He said the agreement "was not worth the paper it's written on."

Kamel Asaad, the speaker of parliament, said, "I expect the agreement will turn a bright new page in the history of Lebanon. We hope it will serve as a turning point."

Analysts credited Sarkis, Asaad and Moslem former premier Saeb Salam, a conservative, with hammering home the agreement. They saw it as a basically Moslem victory, with members of the Shiite sect who suffered in the Israeli invasion of southern Lebanon convincing the Sunni (Moslems) that some limitation must be placed on hitherto freewheeling Palestinian activity in Lebanon.

"Together they seemed to have told the Maronite Christians that it was a take-it-or-leave-it deal," an analyst said, "and that the Christian threats of partition were no longer credible now that the Syrians occupy part of Christian turf and former president Suleiman Franjieh is being pro-Syrian - and thus antipartition - in his northern Christian fiefdom."

Moderate Moslems were apparently banking that the language of clauses covering the Palestinians was vague enough to mollify the guerrillas by talking about the armed "action" rather than questioning their physical presence.

The agreement also called for the construction of a national army, apparently to quiet critics of the Maronite Christians, who are accused by the rest of the country of maintaining a stronglehold over key army commands despite an unwritten understanding that they share them equally with Moslems.

As has been the case with less ambitious agreements in the past, the new accord's basic weakness is that the state does not posses the muscle to enforce it.

A new army is in the process of being formed, but progress is slow at best, especially at times of crisis such as the Israeli invasion and the recent shooting between Christians and Syrian peacekeeping forces in a Beirut suburb.