King Hassan II's visit to Washington comes at a delicate moment in a complex struggle for power and influence in North Africa that is little understood outside North Africa but which could have major implications for the future of the region.

The most obvious expression of that struggle is the small but persistent war over the former Spanish Saharz, territory partitioned by Morocco and Mauritania in 1975 over the protests of Algeria and a band of indigenous military forces. Those "lost soldiers" fled to Algeria and have since emerged as the disciplined and well armed Polisario guerrilla organization.

Chiefly because of the war, Morocco has rarely appeared more isolated in the region than now, when it gives the outward impression of being the most stable and trouble-free of the countries of North Africa.

Mauritania's four-month-old military government has decided in effect to cut its losses and get out of the struggle over the Western Sahara. To Hassan's chagrin, the soldier-rulers are dealing with Algeria to do it.

Algeria, backed by the Soviet Union, long has been their regional rival of Morocco, whose monarchy traditionally has aligned with the West.

Algers, meanwhile, has been seized for nearly two months by a slow-motion presuccession crisis. It has become increasingly clear that President Houari Boumediene's mysterious stay of more than a month in the Soviet Union was made necessary by a grave, perhaps fatal illness.

The French magazine Paris-Match this week indicated that he had cancer. The large range of rumors about what is ailing the Algerian chief of state has finally shaken down to a consensus among professional analysts that he has grave kidney proglems that could only be treated in a major medical center.

Boumediene returned to Algeria Tuesday and his plane reportedly landed at a military airport out of public view. Some analysts here say the pieces of the medical puzzle suggest that Boumediene, 51, may not get through 1979.

Pro-Western Tunisia, which has sometimes been able to play a balancing role in North Africa despite its small size, is beset with grave internal problems compicated by the need to deal with the declining years of the father of Tunisian independence, Habib Bourguba, 75. Intimates say he is subject to fits of almost uncontrollable euphoria alternative with somber periods of inactivity.

When Euphoric, Bourguiba comes up with grandnose schemes. One of them leaked from his entourage was a plan to change the country's bank notes and to inaugurate the change personally in a helicopter tour of the interior during which he would rain new dinar bills down on the population.

Bourguiba has been away in Europe for medical treatments for almost as long now as Bourmediene was in Moscow. This week, Bourbuba sent his premier and heir apparent, Hedi Noulra, a telegram from Bonn saying he has never felt better.

Mauritania's new leader, Gen. Mustapha Ould Mohammed Salek, let the French government understand in a recent visit to Paris that he does not dare ask Morocco to withdraw its 9,000 soldiers in Mauritania. Nevertheless, the 17,000-man Mauritanian army has retired to its barracks and has given the Polisario free run of the country.

Returning travelers say Polisario Land Rovers circulate without hindrance in Mauritania, including the capital of Nousakchott, and in the Mauritanian zone of the Western Sahara. The Moroccan forces are said to have suffered heavy losses recently in Polisario attacks directed not from the Polisario's traditional staging points in Algeria, but from the Mauritanian zone of Sahara.

The French, who had been flying air cover in Mauritania for the Mauritanian army, refuse to go after the Polisario in the Sahara territory.

Polisario use of the territory plays directly into the hands of Hassan when he argues that he cannot allow Mauritania to go through with its informal proposal to let the Polisario establish a federated state in the Mauritanian part of Western Sahara. Morocco insists that if Mauritania goes through with its proposal to allow Polisario to establish a federated state it would only be a base for skirmishing with Morocco to win back all the territory.

One of the main goals of Hassan's visit to Washington is to try to unblock U.S. Congressional restrictions against selling Morocco more F5 combat support jets along with OV-10 recounaissance planes and Cobra helicopter gunships to pursue the Sahara war.

The U.S. Embassy in the Moroccan capital of Rabat reported that Hassan postponed his visit to Washington, which was to have taken place a year ago, out of pique over the Congressional restrictions.

The king issued broad hints this fall that he might postpone the trip again unless he could get advance assurances of American arms. But U.S. diplomats apparently persuaded him that the time was ripe for him to plead his case in Washington.

Hassan is said to feel strongly that the West owes him gratitude for supplying troops two years in a row against rebels in Zaire's Shaba Province and for backing Sadat's peace efforts with Israel.

Bounediene's disappearance from the political scene might make Morocco's need for American arms less pressing. Algerian backing for the Polisario is generally regarded in Algiers as Boumediene's personal hobby horse. None of the small group of military men likely to succeed him, singly or collectively, is known to share his enthusiasm for the war.

In many ways, the Sahara war has been an Algerian-Moroccan struggle waged through surrogates. Soon after the coup in Mauritania, serious fears were expressed in Paris - the Western capital closest to the situation since all the countries involved are former French dependencies - that open warfare might erupt between Algeria and Morocco.

A number of border incidents were reported, especially after Hassan delivered a particularly tough speech Aug. 20. Since then, the Moroccans seem to have relaxed somewhat as they realized that it is a lot easier for Mauritania and the polisario to say they want peace than to make it. Their peace talks in Bamako, capital of Mali, have bogged down over the realities of trying to accommodate the conflicting demands of their more powerful allies, Algeria and Morocco.

The Mauritanians are reliably understood to be toying with bringing at least some of the more moderate Polisario leaders into the Mauritanian Cabinet.

Most observers agree that Boumediene's departure should logically lead at least to a disengagement in the Algerian-Moroccan cold war. But some of these observers not that the real conflict between socialist Algeria and business-oriented Morocco is going to come as both countries broaden their current southward drives for influence at the end of North Africa's traditional caravan routes, in black Africa.

The Algerian army is rushing to complete the hundreds of miles of blacktop it has laid for a trans-Saharan road from Algiers to Kano in northern Nigeria, where the old Arab slave traders used to bring their salt in exchange for wood, cattle and men.

Morocco's close relations with pro-Western Senegal; Ivory Coast and Zaire - viewed in that context - are as much in Morocco's own interests, analysts here note, as they are a favor for the West.