From the air, the sand walls built by Morocco to keep out Polisario guerrilla raids seem to stretch across the western Sahara desert without end, punctuated every three of four miles by forts that look like those children make on beaches.

Most of Morocco's Army in the contested territory of the former Spanish Sahara 600 miles south of here sits dug into the miniforts, behind 400 miles of land mines and surrounded by barbed wire and radar.

Its mission is to protect the 103,000-square-mile territory claimed by the Libyan- and Algerian-backed Polisario as the Saharan Arab Democratic Republic but absorbed by Morocco as its rightful heritage from precolonial times.

"The security belt is not a Maginot Line, but rather an obstacle to infiltration," said Col. Naji Mekki, a French-educated professional who fought against Israel on the Golan Heights in 1973 and now commands troops guarding a large chunk of the nine-foot-high wall.

As an obstacle, in the assessment of Moroccan and foreign military specialists in this North African country, the wall has indeed halted most infiltration into the main population centers that King Hassan II has defined as the "useful Sahara."

In the last few weeks, however, the six-year-old war for control of this Arab wasteland has shown signs of expanding beyond infiltration and Polisario's traditional hit-and-run raids. As a result, Hassan is seeking increased military and diplomatic help from the United States. And the Reagan administration, in response, is considering providing U.S. training that would add search-and-destroy commando tactics to the Moroccan military's mostly static defenses.

Francis J. (Bing) West Jr., assistant secretary of defense for international security affairs, said during a visit in Morocco with a 23-member U.S. military team that the administration will try to provide U.S. radar detection and jamming equipment, which is used to defend against ground-to-air missiles, for Hassan's American-made F5 and French-made Mirage I warplanes.

In doing so, West appeared to accept Morocco's charge that Polisario has deployed Soviet-made SA6 missiles since a major battle Oct. 13 at the desert outpost of Guelta Zemmour, gaining the capability of downing even high-flying Moroccan ground support or reconnaissance planes for the first time since the conflict began.

Western military experts who have been following the war raised the possibility that the five Moroccan planes shot down around Guelta Zemmour might have been hit by SA9s -- heat-seeking missiles that do not use the radar guidance devices that the U.S. equipment is designed to thwart.

Polisario guerrillas previously had used only shoulder-fired SA7 missiles, which are unable to hit high-flying Moroccan reconnaissance aircraft. The SA9, according to U.S. experts, is an upgraded version of the SA7, with greater speed and altitude. Its introduction, along with T54 tanks reportedly used at the Guelta Zemmour battle, represents what Moroccan and foreign military experts here view as a significant increase in the quality of Libyan-supplied weaponry for the guerrillas.

In a conversation with the head of Morocco's Air Force, Col. Maj. Mohammed Kabbaj, West strongly suggested that part of the response should also be a shift to more aggressive and mobile tactics by Morocco's 150,000-man armed forces and that the United States is prepared to offer training to meet this end.

"We can train General Dlimi's forces," West was overheard saying to Kabbaj in the bar of Fez's best hotel. He referred to Gen. Ahmed Dlimi, chief of Hassan's armed forces.

As an example of what should be done, West cited an Egyptian behind-the-lines raid in which commandos destroyed a Libyan air base during the brief Egyptian-Libyan border war of 1977.

Then, called to a telephone in the Fez hotel bar, West was overheard talking with an aide in Rabat and referring to CIA Deputy Director Bobby Inman, Deputy Secretary of Defense Frank Carlucci and "the station chief," the designation given the top CIA officer in embassies abroad. It was not clear whether these references meant the CIA would play a role in any U.S. military aid.

Although the extent and nature of U.S. help are still under negotiation, Hassan has urged increased U.S. help for the war, particularly since last May's defeat of president Valery Giscard d'Estaing in France robbed him of a personal friend and reliable military ally. In addition, the administration in Washington has signaled its readiness to back U.S. friends in the region.

"The leadership of the Reagan administration has stated that your country's concerns are my country's concerns," said Ambassador Joseph Verner Reed Jr. in remarks prepared for his presentation of credentials last week in Hassan's opulent throne room. "The United States will do its best to be helpful in every area of need that may arise. Count on us. We are with you."

In his greetings, Hassan expressed satisfaction at the appointment of Reed, whom he had known for years during Reed's career with the World Bank and Chase Manhattan Bank as David Rockefeller's chief-of-staff. The king contrasted his hopes for more active U.S.-Moroccan cooperation with what he called "pettiness" under previous administrations.

As these hopes are being taken up in negotiations for more military help, the Moroccan Army continues to build new miniforts at intervals along the sand wall, which Moroccan troops call a "security belt."

The belt stretches in a great arc from Tan Tan in the northeastern Sahara near the Atlantic Ocean, curving southwest 400 miles to Bucraa, a phosphate-rich area in north-central Sahara. Construction began Sept. 18, 1980, to some derision from non-Moroccan military observers. Eight months later -- May 14, 1981 -- the artificial sand dune was completed and apparently successful.

And that is what the belt is: a man-made, bulldozer-shaped sand dune, interrupted regularly by sand forts. Some forts contain artillery batteries, which are dug into the desert -- as are the artillery men who live in small individual dugouts underground. Others are infantry positions and tank placements.

Land Rover patrols constantly monitor the walls to make certain no infiltrators have penetrated it.

The desert itself is unlike any that appears in American movies. Rather, it is paved with broken black rock. It looks black except where the bulldozer or the wind has scraped through the sand. Every possible cliche applies. It is wind-swept, Godforsaken, desolate, a wasteland. One wonders who would want it or why.

Still, there is a fascination with the Sahara. Mekki says there is "Sahara ill," a kind of Potomac fever. Some soldiers, he says, have been posted in the former Spanish town of Semara for 10 years in spite of the scorpions, the poisonous snakes, the heat and the cold, and do not want to leave. Mekki has been here for a year.

Semara was a religious center in the last century. Today, the old village is abandoned and civilians and headquarter troops live in a "new" town with colorful, domed buildings. The domes are a Spanish-designed method of desert "air conditioning." There is a small airstrip at Semara, but the features that dominate the desert horizon here are two huge telephone transponders that look surrealistically like giant radars.

Semara is a key center for directing defenses against potential Polisario infiltrators. Since the wall went up, there have been only three attempts to breach it. Twice last April, according to Mekki, "the enemy" attacked with two to three regiments -- about 1,000 men -- to stop construction of the wall. They were repulsed. Then in July, there was another regimental-strength attack on the completed wall. This, too, was repulsed, Mekki said.

Since these abortive raids, all apparently has been quiet in this region of dispute. Guelta Zemmour is about 100 miles south of here, well outside the wall.

The war, as such, had its roots in the Spanish pullout from this area, then known as the Spanish Sahara, in 1976. At that time Morocco and Mauritania divided the area. Two years ago, Mauritania decided it no longer wanted its share and pulled out. Morocco, renewing its claim to the entire region, occupied the territory.

Morocco's desire to absorb the region has less to do with the phosphate deposits in the area than with its nationalistic claim. Moroccans seem united on this point and will tell strangers two things without hesitation:

* Under French and Spanish domination the area always was considered a part of Morocco, held by colonial Europeans;

* Historically, the Saharan tribes paid fealty to Moroccan sultans, demonstrating that the population should fall under Moroccan authority now.