Somalia always held a fascination for President Carter and his adviser Zbigniew Brzezinski, long before the U.S. position in the Persian Gulf deteriorated and the urgent need for a new bases became major foreign policy issues.

Yet, all along, they have been playing with fire.

The new agreemment to secure the use of the old Soviet base of Berbera on the Somali coast, in return for a supply of U.S. arms to Somalia, is merely the latest move in what Brzezinski once described as the modern equivalent of Fashoda.

Fashoda, Brzezinski told a New Orker repporter, was where the British and the French confronted each other in 1898 during their rivalry over control of the Upper Nile.

Fashoda, he said, was a foreshadowing of the type of Soviet-American clashes to come,"sporadic violence, in the context of a premium on preemption, [that] may have a suction effect on U.S. and Soviet intervention forces resulting . . . in some unprecedented confrontations."

Brzezinski made this analogy at the height of the administration's great internal battle on policy toward the Horn of Africa in early 1978. He was then attempting to persuade the president to support the Somalis if they were invaded by Ethiopia with Cuban and Soviet support. A naval task force was one of his more dangerous ideas.

Although Brzezinski did not get his naval force, U.S. policymakers made a number of serious mistakes in the Horn that the Berbera decision will only compound. It's worth a few lines to trace what exactly happened.

It all began with the coup that overthrew Haile Selassie, the late emperor of Ethiopia, in 1974. The Soviet Union at first kept its distance. e

However, when the Ethiopian revolution moved rapidly left in early 1977, the Soviets could not miss an opportunity. They thought that under the umbrella of revolutionary dogma they could work both sides of the street: keep their base in Berbera and get closely involved in supporting the Ethiopians.

In this situation the United States could not resist playing "Fashoda," even if it meant putting some dearly held international principles aside. The United States began to talk to Somalia about arms sales, although it was aware that the Somalis were supporting rebel groups in the Ogaden region of Ethiopia, contrary to the longstanding U.S.-endorced policy of the Organization of African Unity to respect colonial boundaries.

Even when Somali regulars went into the Ogaden in the late July 1977, the United States was slow to respond.

Weeks later, the situation was spinning out of control. The war in the Ogaden heated up. The Cubans came into Ethiopia in November in large numbers backed by Soviet military supplies, and it looked for a moment as though the Cuban-Ethiopian forces might not only sweep the Ogaden clear of Somalis but also burst over into Somalia itself.

The United States threatened to shelve the SALT negotiations if this happened. Brzezinski argued for his naval force.

The whole sequence of events, if it proved anything, showed up the weakness of the U.S. involvement with Somalia. It put American prestige behind a cause that was irrelevant to U.S. interests. The United States got drawn into an old ethnic disput that the Soviets and Cubans were the better placed to exploit, since international law was clearly on the Ethiopian side.

The only positive outcome was the Soviets' loss of Berbera. However, since they also had a more useful base at Aden in South Yemen, this was not critical.

For two years, the situation has simmered on without big power confrontation. The Cubans and the Russians got increasingly bogged down in Ethiopia, the war in Eritrea and the continuing unrest in the Ogaden.

The United States, standing calmly on the sidelines, showed both how silly it was to have gotten involved in the first place and, more importantly, shortsighted the Soviets and the Cubans were to have cast their lot with Ethiopia.

The new arms deal with Somalia could turn back the clock. Already confusion is setting in. Last week, Richard Moose, the U.S. assistant secretary of state for African affairs, told the House Foreign Affairs Africa subcommittee that the United States has been assured orally and in writing that the Somalis will not introduce regular forces into the Ogaden. On the same day, the CIA told the same subcommittee that elements of three Somali regular battalions are already there.

This time around, however, the decision involves not just an arms deal but U.S. use of the Berbera base. Another Ogaden war, when inevitably that the Somalis would use their newly acquired American weapons -- whatever the official U.S. reservations -- would bring the Fashoda factor back into focus.

This time, if the Ethiopians threatened to retaliate by entering Somalia, the United States would have a base at stake. I could quickly look like a U.S.-Soviet proxy war, something which Somali President Mohammed Siad Barre might like to provoke if he thought it would help his Ogaden cause.

This is just the kind of hole the United States should avoid getting sucked into.