Alexander Haig, a smooth operator with a martial air who nevertheless has the brains and guile to be a superb secretary of state, will get an early test of his diplomatic skills when he tries to set U.S. policy in North Africa.

He must figure out how to cultivate a new friend, Algeria, without alienating an old one, Morocco. The two neighbors -- conservative, monarchical Morocco and left-leaning, socialist Algeria -- have long been at odds politically.

Their hostility also involves a vast stretch of valuable desert called the Western Sahara. Morocco's claim to this tract has been contested for five years by the Polisario national liberation movement. These leftist guerrillas get their strongest outside support from Algeria.

Before the Iranian hostage crisis, the U.S. choice was simple enough. Morocco's King Hassan was a staunch American ally who risked the enmity of other Arab leaders to support the Camp David accords. Algeria, on the other hand, channeled arms and aid from the Soviet Union to the Polisario guerrillas. This provoked Hassan to divert American military aid into the Western Sahara, despite legal strictures that required Morocco to use the arms for defense only.

But things have changed. The United States is suddenly in the middle. The Algerians, who volunteered their diplomatic services in the negotiations that led to the American hostages' release became heroes overnight. That puts Haig in a bit of a bind: Morocco is clamoring for more U.S. weapons -- an action that would obviously offend Algeria. As one expert put it to my associate Dale Van Atta: "Should we embrace the prodigal son more than the son who has been good to us for years?"

The appearance of ingratitude toward our new friend must be weighed against the danger to our old ally. The desert war has sapped Morocco's resources, caused internal discord and seriously weakened Hassan's once-stable regime. Algeria's responsibility for the Western Sahara independence movement has helped bring Hassan to this sorry state.

"Algeria has provided Polisario guerrillas with arms, training, some military advisers and a few regular army units, as well as a logistics base and sanctuary," a top-secret CIA document reports. The support is doubly valuable, the report notes, because "the Algerians are experts at desert guerrilla warfare, drawing on their years of experience against the French."

The points are reiterated in another CIA analysis, which says: "The [Polisario] Front-depends mainly on Algeria for arms, training, supplies and financial support; some Algerian military personnel are accompanying the guerrillas in combat operations. A substantial increase in guerrilla operations could only occur as part of an Algerian move."

As powerful and popular as they are, the guerrillas' ability to wage a war of attrition against Morocco would evaporate "without direct Algerian support," the CIA experts conclude.

Hassan must find a way to end the increasingly unpopular war. And for him, the only acceptable way is to beat the guerrillas in field, giving himself the upper hand in any peace negotiations.

Faced with the predicament of an old and valued ally, the State Department has come down on the side of Hassan however much it offends the Algerians -- and has indicated its intention to sell Hassan more than 100 tanks. To lessen the bad public-relations effect, State has sought to portray the Algerians' help with the hostages as the repayment of an old debt, rather than the incurrence of a new one. Reminders were floated around that in the 1960s John F. Kennedy, both as a senator and as president, spoke out on behalf of the Algerians in their struggle for independence from France.

Interestingly enough, the Algerians themselves publicly recalled the Kennedy connection, commenting graciously that "good begets good." The remark suggests that the Algerians consider their debt of honor repaid. And as pragmatic politicians, they are probably under no illusions that sentiment or gratitude will outweigh the United States' longtime commitment to King Hassan -- certainly not with Haig running things.