Senegal's President Leopold Sedar Senghor resigned today after 20 years as chief of state, bringing to an apparent end a career that made Senghor a dominant figure not only in Africa's political move to independence but also in black cultural and philosophical writing. He is also recognized as one of the French language's leading living poets.

Typically, Senghor initially had announced his intention to resign not to his own people but in an interview last month with the Paris daily Le Monde. hAn announcement today in Dakar, the capital of the West African nation, said Senghor would leave office at midnight and that Prime Minister Abdou Diouf, 45, would be sworn in on New Year's Day to complete the presidential term scheduled to expire in 1983.

While the aging Senghor had said for some time he planned to step aside for younger leaders, his action today represented a significant move both for Africa, where peaceful transfers of power from the generation that won independence to younger politicians have been few and far between, and for Senegal.

Much more than the father of a small country noted for its political maturity, carefully controlled democracy and pro-Western moderation, Senghor, 74, is also considered a leading French-language thinker and writer. He is the creator of a trail-blazing philosophy of black consciousness known as negritude and, along with his friend and fellow-president Felix Houphouet-Boigny of the Ivory Coast, the last universally recognized political sage of French-speaking Africa.

Houphouet and Senghor both served as French cabinet ministers. But Houphouet has achieved recognition as a proud nationlist while Senghor preserved the image of a French intellectual who also became a national leader. He gives the impression that, for him, the defense of the world stature of the French language, for instance, is at least as important as Senegal's national interests.

It is an image that Senghor himself has nutured, coquettishly denying against all evidence to the contrary that he is not a shrewd politician -- a quality he had to have to dominate for 20 years the complicated ethnic and racial reality of Senegal's 5 million people in a territory the size of Kansas just south of the frontier between black and Arab Africa.

He leaves power with his considerable prestige intact just as his country seems to be about to face its hardest times since independence. Yet, no one can accuse him of quitting abruptly or of leaving the country in the lurch. The transfer of power is expected to be smooth, the first example in the memory of African specialists of an elected black African leader voluntarily giving up power.

In 1976, Senghor prepared the way with a constitutional amendment providing that the prime minister automatically succeeds the president and finishes the term in case of death or resignation -- a provision that exists elsewhere in Africa only in Tunisia and Cameroon. So he has passed on his mandate to his prime minister of 10 years, Abdou Diouf, a shy man known for his administrative competence, rigor and austerity.

As Senghor's faithful servant, he quietly deflected the criticisms that the philosopher-president was paying less and less attention to the country's daily problems to travel worldwide collecting what may be the world's most impressive string of honorary degrees, from Harvard to the prerevolutionary University of Tehran.

It is widely assumed that the honor Senghor now most covets is the Nobel Peace Prize. He has worked hard to create and preserve cultural and institutional links among Black Africa, the Arab world and Western Europe, publicly noting that he was the one who originated the ideas in those domains that French President Valery Giscard d'Estaing has taken over.

"I have always considered," he said in a current interview in his typically sweeping fashion, "that the African continent went as far as the borders of Iran. That's why I have often spoken of the trilogy of suffering peoples, the Negro-Berber-Semitic ensemble taking in both the Jews and the Arabs."

Within Senegal, a country that is 85 percent Moslem, the Catholic Senghor has played a successful balancing act with his careful cultivation of the marabouts, the mutually jealous Moslem religious leaders. He did not, however, come to terms with the local disciple of Iran's Ayatollah Ruhollah Khomeini, who whipped up a wave of Islamic revolutionary protest in Senegal's universities. The dissident leader, Khalifa Niasse, fled to exile in Libya, provoking a stream of statements from Senghor against the "imperialism" and "racism" of Libya's leader, Col. Muammar Qaddafi.

Convinced that there was a Libyan backing for an attempted coup in neighboring Gambia, an English-speaking coastal enclave in Senegal, Senghor rushed in several hundred troops to protect the Gambian government.

Despite his obvious attachment to rhetoric, Senghor can be pragmatic. He recently said he had decided to return 10 percent of the economy to private hands to get it out of the hands of "bad managers." Yet, saying "my task is not finished," he plans to devote himself to promoting a Socialist Interafrican grouping of states that are neither Marxist-Leninist nor capitalist.

He also plans to devot himself to finishing a long list of writing projects, his French wife of many years and his country residence in Normandy.

With his prestigious univerisity-level teaching degree in French grammar, one of Senghor's pet projects is the creation of a Commonwealth of French-speaking states that would defend the world position of the French language "that is particularly threatened by the laxness of the French themselves." It is a situation that, for him, illustrates one of his constant themes: "Ignorance is the cause of all ills."