Lebanese President Amin Gemayel called today for the immediate withdrawal of all foreign forces from Lebanon and asked the United Nations to extend the mandate of its own peace-keeping troops in southern Lebanon to help the Lebanese government assert its control.

The U.N. Security Council, after hearing Gemayel in a rare appearance by a president, agreed tonight to extend the mandate of the 7,000-man U.N. Interim Force in Lebanon for three months, until Jan. 19.

In an impassioned address to the U.N. General Assembly, Gemayel charged that foreign forces, using Lebanon as "the stage" for their own conflicts and claiming a "divine right to interfere in our affairs," were responsible for eight years of continuous warfare.

"In the name of the Lebanese people, I want to tell you we have had enough," Gemayel said. "Enough of bloodshed, enough of destruction, enough of dislocation and despair."

Requests for military ssistance and the estimated $10 billion reconstruction effort in Lebanon are expected to be among the main topics on Gemayel's agenda when he meets with President Reagan at the White House Tuesday.

In both his speeches here today, Gemayel repeatedly stressed what he described as Lebanon's solidarity with the Arab world. But supporters of Israel were pleased that he mentioned that country explicitly by name, implying recognition of its right to exist, which no other Arab nation except Egypt has so far been willing to do.

The implied recognition, however, came as Gemayel seemingly endorsed the idea of a Palestinian state, which is anathema to Israel.

He said he thought that Palestinians should be allowed to "live in peace and freedom and self-determination in their land, Palestine," adding that his government hoped that "Palestinians and Israelis, with the support of the world community, will reach a settlement that will allow them both to enjoy the fullness of rights."

But he made no mention of any peace treaty between Lebanon and Israel, which the Israelis have been pressing for, and he suggested to the Security Council that the existing armistice with Israel, which was signed in 1949, "is threatening once more to collapse due to the persistence of the Israeli-Palestinian war."

Recalling that Lebanon and Syria had always been "close in the past," Gemayel said that friendly relations between the two countries could be resumed, but he made it clear that this would be conditioned on Syria, like all other "non-Lebanese forces," withdrawing immediately and unconditionally from Lebanon.

Israel and the PLO control other parts of Lebanon.

While he referred generally to the suffering in Lebanon in the years of fighting there, Gemayel did not discuss in any of his remarks the rampage of killings of hundreds of men, women and children in two undefended Palestinian refugee camps by right-wing Christian militia units in September.

Nor did he talk about imposing the will of the Lebanese Army in Christian East Beirut, where Phalangist private militia have ruled for seven years.

The Lebanese Army, in two weeks of house-to-house searches for weapons in Moslem West Beirut, has disarmed private militia there and restored the government's authority, but Gemayel postponed similar operations in East Beirut until after his visit here.

In his addresses, Gemayel chose to emphasize what he described as the disruptive effect of the conflicts of foreign forces on Lebanese soil, which, he said, had converted the country "from a haven for culture and peace into an arena for terror and violence."

"The war blurred many images," he said. "We could not, for example, tell who was the friend and who was the foe. All seemed to be bent on the destruction of our peaceful way of life."

"Each foreign force claimed a divine right to interfere in our affairs and denied us the right to speak for ourselves. And thus, by forces beyond their control, the Lebanese were alienated from themselves."

Gemayel said he thought that there was a sharpened national consensus developing in his country in the wake of the assassination of his younger brother, President-elect Bashir Gemayel. He pledged to maintain Lebanon's "cultural plurality" but he said that diversity was inseparable from "political oneness."

In attempting to explain why it was Lebanon that became what he described as the stage for tensions among Middle Eastern states, the armed Palestinian presence and recurring Israeli invasions, he said:

"Perhaps [it was] because Lebanon was too democratic, too free -- and even lax . . ."

Gemayel spoke gratefully of international efforts to bring about peace in Lebanon and appealed for postwar help, saying: "We look to our Arab brethren for political and economic support in building a country which can be a source of pride, peace and progress for us and for them.

"Peace in Lebanon is obviously a precondition for peace in the Middle East . . . If Lebanon is stable, so will this region be stable. If it is in chaos, so will be the volatile East."