President Carter coupled his criticism of Cuban military involvement in Africa yesterday with an attack on white racism in southern Africa, saying he hopes for the day when all Africans would cry out, as did Dr. Martin Luther King Jr., "Free at last, free at last, Great God Almighty, we're free at last."

Nearly 5,000 Nigerians assembled at Lago's National Theater gave the president his loudest ovation when he quoted the assassinated U.S. civil rights leader whom Carter called "a great man from my home state."

His speech interrupted by applause more than a dozen times, Carter asserted that the United States is committed "to an Africa that is at peace, free from colonialism, racism and military interference."

But he warned that Cuban troops are preparing to fight against insurgent Eritrean forces in Ethiopia and that the Cuban and Soviet involvement in the Horn of Africa threatens Africa's future.

"The military intervention of outside powers or their proxies in such disputes too often makes local conflicts even more complicated and dangerous and opens the door to a new form of domination," Carter said.

"We oppose such intervention. We must not allow great power rivalries to destroy our hopes for an Africa at peace."

American officials emphasized that the importance of Carter's speech was less in its substance than in the fact that he had chosen to come here - to Africa's most populous nation - to reaffirm basic U.S. policy toward Africa.

Carter mentioned the Eritrean conflict near the end of his speech, underscoring American concern about the continued, and growing, presence of Cuban troops in the Horn of Africa.

An administration official who accompanied the president here told reporters Friday that number of Cuban troops in Ethiopia is now about 17,000, some 4,000 more than the last previous estimate. He said there is "some indication" that they will be "massively employed" against Eritrea, a former Italian colony now governed by Ethiopia.

Carter's speech at the theater, on a day of stifling tropical heat and humidity, signaled no change in U.S. policy toward Africa. Rather, the president sought to reassure Nigerians and other Africans of American intentions, particularly in connection with the explosive situation in southern Africa.

Warning that "the hour is late" in the effort to achieve majority rule in Rhodesia and Namibia, Carter appealed to both black and white leaders to avoid bloodshed.

"The parties must choose," he said. "They can choose the path of agreement, and be remembered as statesmen, men of vision and courage, who created new nations, born in peace. Or they can insist on rigid postures that will produce new political complications, generating conflicts, growing bloodshed and delay the fulfillment of their hopes."

Specifically, Carter reaffirmed U.S. support for the Anglo-American proposal for majority rule in Rhodesia and a revised version of the five-power plan for majority rule in Namibia.

The president also pledged that the United States will continue to press South Africa to move toward majority rule, although he stopped short of endorsing specific action to increase the pressure on the white minority South African government.

"We have made it clear to South Africa that the nature of our relations will depend on whether there is progress towards full political participation for all her people in every aspect of the social and economic life of the nation and an end to discrimination based on race or ethnic origin," he said. "We stand firm in that message."

That is a message the Nigerians are anxious to receive, particularly as it relates to Rhodesia in the two days of talks he will hold here with Nigerian officials, the president is expected to be pressed for a continued commitment to the Anglo-American plan for majority rule and to oppose the so-called "internal settlement" engineered by Rhodesian leader Ian Smith.

Carter seemed to be responding to these Nigerian concern in his speech when he reaffirmed the U.S. commitment to the Anglo-American plan and declared, "This is our nation's policy. We will not depart from it."

The subject of Rhodesia was also expected to come up today when Secretary of State Cyrus Vance meets with the foreign ministers of three of the so-called frontline states that support the Anglo-American plan.

The president's visit here had its own symbolic importance, marking the first time that an American president has made an official visit to a black African nation. But it also represented a recognition of the importance of Nigeria, a former British coloney that is considered an emerging economic and military giant and which is the second largest supplier of imported oil to the United States.

Carter's first full day here began yesterday morning when he was officially welcomed by the leader of Nigeria's military government, Lt. Gen. Olusegun Obasanjo, at the military barracks where Obasanjo lives.

"The whole of Africa, and indeed the whole world, will be interested in your visit to our country as marking a significant redirection in American policy toward black Africa," Obasanjo told the president.

Carter seized this first opportunity to raise the issue of southern Africa, seeking to identify U.S. goals with those of Nigeria.

"Our relationship with you is one of mutual dependence and our goals should always be to find ways of making this relationship even more beneficial to both our people," he said. "And we share the hope of achieving peace with justice in southern Africa."

The two leaders tood in the burning sun to review an honor guard of Nigerian troops before entering Obacanjo's residence for the first of their meetings.

The issues involved in southern Africa were discussed at the meeting, although American officials provided virtually no details about the session.

Following the meeting, Carter was driven to a memorial to dead Nigerian soldiers where, in a sudden rain storm, he placed a wreath.

Last night, the president and his party were treated to a show of native Nigerian folk dancing and music.

Carter rocked in his seat to the beat of native Africa drums, watching the spectacularly colorful show with some 35,000 spectators in a giant outdoor stadium.