The struggle to topple Ugandan leader Idi Amin has resulted in the army of one nation invading the territory of another specifically to unseat its president for the first time in the history of independent black Africa.

It is a precedent that may well return to haunt all of Africa and particularly Tanzanian President Julius Nyerere, whose troops are reported deeply involved in the fighting inside Uganda.

In early January, Nyerere stated catergorically in an interview that "it is not true that we want to overthrow him and install [Milton] Obote," the former Ugandan president who lives in Dar es Salaam.

His troops, he said, would not cross the Ugandan border.

Today, he reportedly has committed 4,000 troops, perhaps more, to doing just that.

Like Uganda's seizure of 700 square miles of Tanzanian territory last October, the Tanzanian action violates a number of basic principles in the charter of the Organizaiton of African Unity - most notably, respect for national sovereignty and noninterference in the internal affairs of another African nation.

Most African nations have been willing to simply sit on the sidelines in the Uganda-Tanzania dispute waiting to see which leader wins. But no African leader has so far publicly condemned the Tanzanian involvement as if they would be content to see Amin disappear from the African scene.

While Africa is probably not particularly shocked that Amin would flout the charter, it may judge President Nyerere differently because of his prestige as one of Africa's leading statesmen and a founder of the African organization.

The rules of the game of intra-African behavior are still very much in the making on this unsettled continent of 49 fragile, black-ruled states, most of which are less than 20 years old.

Despite the lofty principles of pan-Africanism and African brotherhood that raised great expectations on the continent in the early 1960s, independent black Africa has shown an increasing tendency to behave just like older European and American states.

Realpolitik in Africa has forced governments to accept the fait accompli and proof of power regardless of the OAU's principles.

The past five years have seen a number of precedent-setting actions by African nations, the full import of which only time will tell. Morocco and Mauritania in 1976 divided up between them the former-Spanish Sahara, setting off a guerrilla war that still rages on.

Somalia sent its regular army deep into Ethiopia in 1977 in an unsuccessful bid to help Somali insurgents seize the Ethiopian Ogaden region and incorporate it into the main Somali nation.

During the 1975-76 civil war in Angola, a number of African states, in addition to Cuba and South Africa, sent arms, advisers or troops to help one or another of the three contending factions. Among these were Zaire, Nigeria, Mozambique, Algeria, Guinea and Guinea-Bissau.

Angola allowed its territory last year to be used by Zairian exiles to form a large army to launch a major invasion of Zaire's southern Shaba Province.

Angola and Somalia, who failed in their attempts, have generally been concerned in Africa while Morocco and Mauritania have won little support for theirs. How will Nyerere weather his decision to send Tanzanian troops to help overthrow Amin? Will he turn out a hero or villain on the continent?

It is likely that Africa either will applaud or condemn his involvement in Uganda's internal affairs depending upon whether Amin falls or survives. As a result a new principle may emerge from the Uganda episode, namely that an internationally discredited African leader such as Amin is fair game even for another African leader.

Zambia is already defending Nyerere as a "man of peace, vision and integrity." A front-page editorial in the party newspaper, the Times of Zambia, said Thursday that Amin's "horrific rule of blood in Uganda must be ended" and "true friends of Africa must once again be prepared to help."

The history of President Nyerere's feud with Amin goes back to Jan. 25, 1971, the day the towering ex-boxing champion seized power in Uganda, ousting Obote.

In September 1972, Obote - with Nyerere's blessing and assistance-launched his first abortive attempt to bring down Amin. An army of 1,000 Ugandan exiles, trained and armed in Tanzania, invaded southern Uganda but fell to pieces and was crushed by Amin's forces.

The two African leaders have been at each other's throats by word or deed, directly or by proxy, ever since. Nonetheless, until recently, Nyerere kept the remnants of the first Ugandan expeditionary force at work on cotton farms around Tabora.

Amin, who has shown as few scruples in the conduct of his foreign as his domestic policies, pursued for years a plan to march his Soviet-equipped army to the Indian Ocean through Tanzania to seize the Tanzanian port of Tanga and establish a Ugandan corridor to the sea.

For eight years, Nyerere and Amin lived as sworn enemies. The Tanzanian leader refused to recognize Amin's government and when the African organization held its summit in Kampala in 1975 he boycotted it.

Amin replied mostly by taunting Nyerere over Radio Kampala with such gibes as "If he were a woman, I would marry him" and challenging Nyerere to a fight in the boxing ring-Amin was once the heavyweight champion of Uganda.

Nyerere kept his silence. He even forced Obote and his partisans to keep theirs - at least until Amin's last folly of late October. Covering up yet another mutiny in his revolt-ridden army, Amin sent 3,000 troops across the border to occupy the Kagera Salient in northern Tanzania and impose a draconian rule on the 45,000 Tanzanians living there.

It was the final straw - and the end of Nyerere's patience not only with Amin but also the OAU charter.

Ironically, it was this organizaiton's attitude toward the short-lived Uganan invasion that may well have convinced Nyerere that there was no other way to punish and contain Amin. Nyerere could not get the OAU to come out and condemn Amin for his flagrant violation of its own charter.

He was then further enraged by the mediation attempts of half a dozen African leaders, including Sudanese President Jaafar Nimeri, the current OAU president, and the Nigerian leader, Gen. Olusegun Obasanjo. They, according to Nyerere, asked him to forswear the use of force and open negotations rather than drive Amin's troops out.

"What was there to negotiate, our own territory," Nyerere asked in the January interview.

And so independent black Africa seems destined to reap the harvest of the seeds of unrestrained interference in the internal affairs of one state by another that events are sowing across the continent.