Prime Minister Menachem Begin said tonight that the Egyptian-Israeli peace treaty has survived "an important test" because Egypt reacted mildly to the Israeli invasion of Lebanon.

"They did not go to war, concentrate an army," Begin said in a television interview shortly before departing for the United States. "Everything written in the peace treaty exists."

The Israeli prime minister's remarks underline the importance to Israel of Egypt's exit from the Arab confrontation front against the Jewish state through the Camp David peace treaty between Cairo and Jerusalem. Although Egyptian President Hosni Mubarak strongly criticized the Israeli invasion of Lebanon, there was never any indication that Egypt would do anything concrete to impede it.

"The peace treaty between us and Egypt held up," Begin said. "This was an important test."

Begin also hinted that he believes the United States shares at least some Israeli objectives in the 10-day-old invasion, in particular an Israeli demand that the Palestine Liberation Organization must cease to exist as an armed presence in Lebanon. This has evolved as a major Israeli demand for any post-invasion settlement, but Washington has not publicly defined its policy on the matter.

"The Americans also understand now, not only do we, that such a situation cannot be reconstituted by any means," Begin said. "All terrorist organization personnel in Lebanon must be disarmed. If they stay in Lebanon, with the agreement of the Lebanese government, then they have to be as residents, not citizens, but without weapons. In other words, all must change in Lebanon."

Begin, responding to a question, acknowledged that there are "nuances" between Israeli and U.S. positions on the Lebanese war. He declined to reveal what they are, but added:

"We are discussing these matters as friends. In recent days great understanding has been reached between the U.S. government and the government of Israel."

Israeli officials quoted earlier on Israeli radio said Begin told his Cabinet in a pre-departure meeting that the Israeli control of the Beirut-Damascus highway will be a major bargaining card in negotiations for a settlement pleasing to Israel. Defense Minister Ariel Sharon said yesterday that Israeli troops are maintaining a "massive presence" on the key artery, controlling all passage between Beirut and Damascus for Palestinians and Syrians.

Special U.S. envoy Philip C. Habib had to pass through an Israeli checkpoint on his way to confer today with President Elias Sarkis of Lebanon, and Sharon said Habib had telephoned him in advance for a guarantee of safe passage from Damascus yesterday.

Begin indicated Israel will maintain its occupation of the southern half of Lebanon until its demands are met, raising the prospect of a prolonged Israeli presence if the negotiations for a settlement, as expected, prove long and complicated.

"We will be there until all the security arrangements are made to prevent attacks" on settlements in northern Israel that previously were under the range of Palestinian guerrilla artillery, he said.

As has Sharon, Begin left open the possibility that Israeli troops could attack PLO headquarters inside Beirut, striking out from positions around the Lebanese capital. Any such operation likely would prove particularly bloody. The PLO leadership is headquartered in densely populated residential areas of West Beirut and Palestinian refugee camps with large civilian populations.

Asked about Israeli intentions toward "the terrorist nests and terrorist headquarters left in Beirut," he responded: "I cannot answer the question at this time . . . . There is the problem of the field, and in a few days you will find out."

The interview was broadcast on Israeli television as Begin was already airborne on his way to the United States to address a U.N. General Assembly session on disarmament and meet with President Reagan, Secretary of State Alexander M. Haig Jr. and other administration officials.