Libya's backing for an abortive a revolt in southern Tunisita has proved to have a positive side for the United States in North Africa.

The Libyan move come just as the Carter administration was pressing the U.S. Congress to allow a controversial arms sale to Morocco that has been poisoning U.S. relations with Algeria, the other major state in North Africa.

Algeria's reaction was muted as it became clear that in response to America's tough new mood after Iran and Afghanistan, Congress would not block the arms for algeria's rival. There were the predictable editorials in the Algerian press but they threatened no reprisals and left the door open for better U.S. Algerian relations.

The Libyan-inspired attacked on Tunisia a country with twice the population of Libya but one-hundredth the firepowder of his Soviet-supplied arsenal has served as a catalyst for latent trends.

Revolutionary Algeria, with close ties to the Soviet Union, quickly assured the Western-oriented Tunisians that it had nothing to do with the attempt at destabilization and would see to it that the Libyans would never again mount such an operation from Algerian soil. This the new Algerian pragnatism in a strategic region the United States has done relatively little to understand.

It is this same oragmatism that helps to explain Algerian restraint over U.S. arms for Morocco.

A recent two-week tour of Algeria and Tunisia turned up signs of an Algerian willingness to serve as the protector of Tunisia against Libya and to be a force for stability in the region. Until Libya changed the picture, the United States, on which Algeria was once clearly betting as its best outlet to the West seemed to have let itself be outmaneuvered in North Africa -- a region that the 45 million inhabitants proudly call the Maghreh, the Arab word for "west."

The United States often acts as if it is involved in the Maghred in an East-West struggle for influence with the Soviets. This view, encouraged by Moracco's King Hassan II, often seems to lead American policy makers to ignore the regional implications of local conflicts.

The East-West outlook ignores the continued influence of France, the former colonial overlord. In the Maghreb the shared French language, education, culture and love-hate relations with the region's common Arab and Islamic identify.

Algeria and Morocco are involved is a complicated East West equation. Algeria balances off its almost complete dependence on Soviet arms with commerial relations that find the United States its major trading partner.

Ever since the U.S. landing in North Africa in 1942, various French politcians have accused the United States of wanting to displace France as the leading Western influence in the Maghreh.

Sometimes French and U.S. interests coincide, as they did two weeks ago when the French airlifted Tunisian toops against the Libyan-trained attackers in the southern town of Gafsa and the Carter administration announced a speedup in arms for Tunisia.

Just as often, French and American interests seems to diverge.

French diplomats and polticians, with a wealth of colonial experience, have intimate knowledge not only of the rulers and their entourages but also of their opponents and potential successors that their U.S. conterparts cannot begin to approach.

There are about 200,000 French teachers, technicians, businessman and their families still in former French North Africa. About 1.5 million North African immigrant workers and their families live in France.

France seems unlikely ever to be surprised in the Maghreb the way the United States was by the Islamic political movement against the shah in Iran.

It was against this backdrop that France urged the United States to heed King Hussan's pleas for arms while France phased itself out of the war between Morocco and the West Saharan guerrillas of the Polisario Front, backed by Algeria and Libya.

France apparently started moving toward leaving the United States isolated in the Maghreb with Morocco almost two years ago by halting its devastating air strikes against the Polisario. French-protected Mauritania then dropped out of the war and France proclaimed its neutrality in the conflict.

Yet, only now that Congress has cleared the way for the U.S. to send weapons to Morocco, France says it was a mistake for the Americans to arm the King, French and Algerian officials say the Sahara war is no longer an issue between them. Knowledgeable Algerians say the government is considering buying French arms to become less dependent on the Soviets.

Algerian officals make it clear that the only real obstacle to good U.S. relations with Algeria is U.S. support of Morocco against the Polisario -- a piece of excess baggage the French have thrown overboard U.S. officials obviously treat the Sahara war as a sideshow, even though it has conditioned a whole range of North African problems, starting with Algerian-Moroccan relations.

A high-ranking Frenchman heavily involved in Maghreb affairs gave a detailed analysis of why neither Morocco, which controls the strongpoints in the western Sahara, not the tiny Polisario, probably the world's best desert warfare force, can win.

Then, he said, "But of course, Morocco will lose because there must be a loser." As if to justify France's revised bet on who is the Maghreb's winning horse, he recalled that Charles de Gaulle once said that Algeria's revolution is behind it and Morocco's revolution is still to come.

The conflict between the two countries is really of French creation. Knowing that it would someday have to five up its protectorates over theoretically sovereign Morocco and Tunisa, France assigned practically all of the Sabara Desert territories to Algeria, then considered an integral part of France that was to remain French even after decolonization.

So, Morocco's insistence on its "historic" claims to the western Sahara seem to be a genuine worry to the Algerians since Morocco has equally "historic" rights to a large swath of western and southern Algeria.

The Algerians insist they do not want the king of Morocco to lose the war. As a leading Algerian put it, "it's not in the U.S. interest, and it's not in the Algerian interest either, for Morocco to be destabilized. We want a political solution because the last thing we want is a revanchist Moroccan Army on our borders waiting for its moment. But you Americans aren't helping at all. You say you want to give the king arms so that he can be strong enough to negotiate. Look what happened in November when you announced the decision to arm him. He was supposed to be in Monrovia three days after your announcement to take advantage of the best opportunity to negotiate he has ever had, and he canceled the trip."

The Algerian said that his country had agreed for the first time at the meeting of the Organization of African Unity in Montrovia to allow Morocco to keep its troops in the northern zone of the western Sahara -- the part that contains the territory's only currently exploitable resource, the have phosphate deposits at Bon Craa.

Hansan originally took over the territory -- half the size of Texas -- in a bid to restore Moroccan national unity. He is a victim both of the political success of his move and of his failure to win the war that ensued. Everyone, from communists to conservative monarchists, rallied to the cause. Now, said a U.S. analyst, "The king is in the unenviable position of losing a popular war."

The Algerians say privately that it would not brother them at all if the Polisario were to decide of its own free will to enter a confederation with Morocco. Algeria's main concern, they say, is that Morocco should accept the OAU principle of the inviolability of the frontiers inherited from colonialism.

The Algerians complain that U.S. policy is not keyed to such primarily regional concerns. "It's all very well for Carter to say that America can't let its friends down.Does this mean that America's friends can do anything they feel like because Washington feels it can't let anybody down anymore? We feel that we are being made to pay for what happened in Iran . . . We have been trying to keep this a regional problem. U.S. actions will internationalize it. That will draw the Russians in, and we have been trying to avoid that."

It was ironic, coming from a man whose president, Chadli Benjedid, was understood to be telling visiting Italian communists that he, unlike them, could not afford to condemn the Soviet invasion of Afghanistan because all of his arms come from the Soviets.