President Anwar Sadat of Egypt said today he is ready to supply military aid to Morocco for King Hassan's war against Polisario Front guerrillas trying to set up an independent nation in the Sahara Desert.

Sadat's pledge appeared designed to show the Moroccan monarch that, despite his opposition to Egyptian peace policies, he still can count on Sadat's support and would be greeted warmly if he returned to his traditional friendship with Egypt.

Although a long-time ally of Egypt and the West, Hassan has joined 17 other Arab countries and the Palestine Liberation Organization in an economic and political boycott of Egypt aimed at punishing Sadat for signing the March 26 peace treaty with Israel.

He previously supported Sadat's peacemaking efforts, however, and is considered a likely target for Egypt's initial attempts to break the ranks of Arab nations opposing the treaty and the Palestinian autonomy talks set up under its terms.

Sadat made his proposal of support for Hassan in response to reporters' questions at the Mediterranean city of Alexandria, where he received visiting West German Foreign Minister Hans-Dietrich Genscher.

Reports from Alexandria conflicted as to whether Morocco actually has requested military aid, or whether Sadat was merely offering to provide it if such a request were made. In any case, there was no indication what Egypt would actually furnish if a military-aid agreement were concluded.

Sadat underlined his willingness to consider any request, saying: "We will support Morocco 100 percent to the end."

Besides the effort to win back Morroccan support, Sadat underlined his increasing willingness to support other nations in the Middle East and Africa that he feels are threatened by aggression from outside. The United States has encouraged Sadat to assume this regional role, and a massive military-aid program getting under way here is, in some ways, designed to make this possible.

In addition, the gesture of support for Hassan gave Sadat an opportunity to point up his hostility toward Algeria, a leader of the "steadfastness front" formed in December 1977 to counter Egyptian peace policies.

The members of the front -- Libya, Syria, Algeria, South Yemen and the PLO -- are the most violent opponents of Sadat's treaty with Israel. Algeria also is the chief backer of the Polisario Front guerrillas who are fighting Hassan's Army for control of the former Spanish Sahara.

Morocco and Mauritania divided up the desert region almost four years ago after the pullout of Spain's colonial administration.Since then, the Polisario guerrillas have been waging a hit-and-run war to press their claim for an independent Saharan state.

Algeria, particularly under the late president Houari Boumediene, has been their chief backer, providing arms, logistics support, training and rear bases. The Libyan leader, Col. Muammar Qaddafi, also backed the guerrillas with arms and political support.

Mauritania had been the chief victim of the fighting, with the guerrillas raiding at will in Mauritania's northern region and even into the capital, Nouakehott. A new military government that seized power 13 months ago recently made good on its pledge to pull out of the conflict, leaving Hassan to face the Polisario alone.

The monarch has been pressing the United States to increase its military support, particularly for reconnaissance planes and other aircraft effective in hunting down and destroying columns of Land Rovers used by Polisario guerrillas to stage raids on places in the Sahara held by Morocco or within Morocco itself. The United States has been reluctant to do so, however, arguing that the arms would be used outside Moroccan borders.

Hassan has claimed the right to attack guerrillas in "hot pursuit" within Algeria. His conflict with the Algerian-backed Polisario troops has raised fears that a broader war could erupt, pitting his Western-supplied army against the Soviet-supplied military of Algeria.

The Moroccan leader suggested yesterday that President William Tolbert of Liberia, current head of the Organization of African Unity, call a special summit of nations bordering the Western Sahara to help resolve the problem.