In a stunning setback to Prime Minister Menachem Begin's settlement policies in the occupied West Bank and Gaza Strip, Israel's highest court today ordered the government to dismantle the controversial Jewish civilian outpost at Elon Moreh with 30 days.

The unprecedented ruling by a five-judge panel of the High Court of Justice declared that private Arab land seized for Elon Moreh, near the West Bank city of Nablus, was taken for political reasons and not for overriding security needs, as contended by the government.

Coupled with yesterday's abrupt resignation by Foreign Minister Moshe Dayan over West Bank policy disagreements, the court decision threw into doubt the government's ability to expropriate Arab land for the development of purely civilian settlements.

It appeared to force Begin into a position of either having to sharply curtail settlement activity or trying to pass legislation to circumvent the High Court in future settlement plans.

Following a meeting between Begin and Justice Minister Shmuel Tamir, government officials sought to minimize the impact of the ruling, saying new settlements can continue to spring up in the occupied territories if initiated by the military.

But the government said it would abide by the court decision and start evacuating Elon Mareh, which was hastily erected with army help in the early morning hours of June 7 by the ultranationalist settlement movement, Gush Emunim.

The court ruling, while explicitly defending the principle of settlements based solely on defense considerations, came closer than any previous Israeli judicial statement to the long-standing position of the United States that the movement of civilian populations from Israel to the occupied territories is illegal and is an obstruction to the Camp David peace process.

In Cairo, Egyptian officials immediately hailed the decision as a step forward for peace and expressed hope that Begin government would use more restraint in future settlement decisions.

While the Camp David accords largely ignored the issue of Jewish settlement in the West Bank, the proliferation of outposts has lingered in the background as a potential impediment to progress in negotiations for autonomy for the 1.1 million Palestinians in the West Bank and Gaza Strip. Egyptian President Anwar Sadat, for example, has said there can be no real progress in the autonomy talks while Israeli settlements are springing up in the occupied territories.

Attorneys for West Bank Arab landowners hailed the decision as a landmark and interpreted it as meaning that all settlements are unlawful, a conclusion that seems to go beyond the ruling.

The court did invoke, however, provisions of the fourth Geneva Convention and The Hague Convention that forbid the transfer of civilian populations from conquering country into an occupied territory. The court said Israel is obliged to adhere to international law.

The Geneva and Hague Conventions regulate among other things, the conduct of warfare and form a part of international law.

The court ruled that while the Hague convention permits settlement for the fulfillment of military needs and that civilians may be used as an adjunct to that need, this principle does not apply to the purely civilian character of Elon Moreh.

More importantly, the court said that land expropriation for military purposes must, by nature, be temporary and that an outpost cannot be designed to outlive the temporary military administration of an occupied territory.

The court declared that although the right to settle in all of "Eretz Israel" (Palestine) may be founded in Zionism, it does not justify taking private property for other than compelling security reasons.

The court dismissed the argument by Israel's defense forces chief of staff Raphael Eitan that Elon Moreh is strategically necessary for Israel's security because if overlooks the crossroads of the main Jerusalem-Nablus road and the east-west trans-Samaria road. The court said the sequence of events in Elon Moreh's approval by various government bodies proves that the settlement was politically inspired.

The court noted that the army was not consulted about Elon Moreh until two Cabinet committees approved the settlement. Also, the approval came after Gush Emunim conducted demonstrations to pressure the government.

Moreover, the court said, experts disagreed over the military necessity for the outpost, a reference to testimony by former chief of staff Haim Bar-Lev and retired Gen. Matti Peled that the site is strategically unimportant.

Ironically, Gush Emunim may have contributed itself to the court's decision by declaring in affidavits and testimony that the Jewish biblical right to settle in the West Bank was the primary purpose of Elon Moreh and that security needs neither added to nor detracted from the mystical motive.

Cabinet Secretary Aryeh Naor said that "the direct implication of the decision is that . . . the government wil have to obey it. We have nothing to do but carry it out. We are a state of law." But, Naor said, "maybe some day the laws will be changed."

The difficulty in legislating nonsecurity settlements is that such a law would appear to be a violation of the Haue Convention provisions restricting occupation activities to military principles and could be overturned by the High Court for the same reasons cited today.

Moreover, Labor opposition alignment leader Shimon Peres said today if Begin's Likud coalition attempts to pass any law that implies violation of the Hague Convention, it will fail in the Knesset (parliament).

The high court decision, which was based on an appeal brought by Arab landowners in Rujeib whose land was seized, was hailed by Palestinian leaders and condemned by Gush Emunim.

Some Gush Emunim leaders said that Elon Moreh, named after the first settlement built by Abraham, would resist evacuation and that 50,000 squatters would go there to demonstrate.

"Ten battalions won't get us out," said one Elon Moreh resident. Since the court on June 20 temporarily halted construction at the site, only a handful of settlers have remained.

Bernie Katzover, Elon Moreh secretary, said, "We believe now the government will understand that the direction to go is to change the law and not take land for security reasons but for national reasons."

Gush Emunim lawyer Rahamim Cohen said, "Now the government will be obligated to take land in order to arrange Jewish settlements without the pretext of security needs."

Interior Minister Yosef Burg, titular head of the National Religious Party, which is allied with Gush Emunim, said he felt sorrow" over the court ruling. He added, "The government will study the question of what to do from the point of view of jurisprudence and from the point of view of Zionism."

Labor Knesset member Yosi Sarid said, "If the government wants to continue settlements, it will have to declare openly that it is annexing the West Bank."

The peace Now movement which on Saturday night attracted 40,000 people to a demonstration in Tel Aviv against settlements called the ruling an "important step in the struggle for the rule of law."

Elias Khouri, the attorney for the Rujeib landowners, said the decision means " the government does not have carte blanche to set up settlements for any reason at all."

Dayan, meanwhile, said tonight he believes that the government will take legal steps to try to save Elon Moreh, although he avoided making a judgment on the court decision.

Dayan voted against the expropriation of land for Elon Moreh, saying at the time he felt it would impede the peace process.

Coupled with today's court ruling, Dayan's resignation appeared to lend impetus to the growing movement among moderate and leftist Israelis against West Bank settlement, and peace activitists predicted a series of demonstrations against Begin's settlement policies to keep the momentum going.