Diouf was born in Louga, Senegal, the child of an Halpulaar mother and a Serere father. He went to primary and secondary school at the Lycée Faidherbe in Saint-Louis, and studied law at Dakar University and then at the Sorbonne, Paris. Diouf graduated in 1959.
After graduation, Diouf returned to Senegal, where in September 1960 he was appointed Director of International Technical Cooperation. In November 1960 he became assistant of the Secretary-General of the Government and in June 1961 he became Secretary-General of the Ministry of Defense. In 1961 he joined the Senegalese Progressive Union (Union Progressiste Sénégalaise, UPS), which later became the Socialist Party of Senegal. In December 1961 he became Governor of the Sine-Saloum Region, serving in that position until December 1962, when he became Director of the Cabinet of the Ministry of Foreign Affairs. In May 1963 he was moved to the position of Director of the Cabinet of President Léopold Senghor, where he remained until December 1965. In January 1964 he became Secretary-General of the Presidency, serving until March 1968 when he became Minister of Planning and Industry. He remained in the latter position until February 1970, when he was named Prime Minister.
In 1970, Senghor reinstated the post of prime minister, giving it to Diouf, his protégé. Senghor trusted Diouf, who had administrative experience but no independent power base of his own. This was important, for Senghor's last prime minister Mamadou Dia was accused of using the position to launch a coup d'état. On January 1, 1981, Senghor resigned in favor of Diouf, who became president of Senegal.
Diouf continued the political liberalization Senghor had begun by holding elections in 1983. He allowed fourteen opposition parties to run, instead of the four Senghor had allowed. The practical effect of this was to fragment the opposition, and Diouf won with 83.5 percent of the vote.
In 1985, opposing parties tried to form a coalition. It was broken up on the grounds that coalitions were forbidden by the constitution. Also in 1985, Abdoulaye Wade, Diouf's main political opponent, was temporarily arrested for unlawful demonstration.
In February, 1988, elections were held again. Diouf won 72.3 percent of the vote to Wade's 25.8 percent, and opposing parties alleged electoral fraud. Disturbances followed, and Diouf declared a state of emergency, detaining Wade again until May of that year.
Under Diouf, Senegal agreed to form a confederation called Senegambia with neighboring Gambia on December 12, 1981; this union took place on February 1, 1982. In April 1989, the Mauritania-Senegal Border War developed, leading to an outbreak of ethnic violence and the severing of diplomatic relations with Mauritania. As the region destabilized, Senegambia was dissolved.
In 1986, Diouf began an anti-AIDS program in Senegal, before the virus was able to take off in earnest. He used the media and schools to promote safe-sex messages and required prostitutes to be registered. He also encouraged civic organizations and both Christian and Muslim religious leaders to raise awareness about AIDS. The result was that while AIDS was decimating much of Africa, the infection rate for Senegal stayed below 2 percent.
Diouf was reelected in February 1993 with 58% of the vote to a 7-year term; presidential term lengths had been extended by two years in 1991. In the first round of the 2000 elections, on February 27, he took 41.3% of the vote against 30.1% for the long-time opposition leader Abdoulaye Wade, but in the second round on March 19 he received only 41.5% against 58.5% for Wade. Diouf conceded defeat and left office on April 1.
From this electoral defeat came one of Diouf's greatest contributions to African peace, for he gracefully surrendered power to Abdoulaye Wade, his long-time rival. When Diouf left office, Wade even said he should receive a Nobel Peace Prize for leaving without violence.
Diouf was Deputy Secretary-General of the Socialist Party under Senghor. He became Secretary-General in 1981, and when the party was restructured at its Thirteenth Congress in 1996, he was moved to the position of President of the PS, while Ousmane Tanor Dieng became First Secretary, having been proposed by Diouf.
Both during and after his presidency, Diouf has been active in international organizations. He was President of the Organization of African Unity (OAU) from 1985 to 1986. Soon after his election, he made a personal plea to François Mitterrand, the President of France, resulting in France speaking strongly for sanctions against South Africa. In 1992, he was re-elected President of the OAU again for another year-long term.
After leaving office as President of Senegal, he was unanimously elected as Secretary-General of La Francophonie at that organization's Ninth Summit on October 20, 2002 in Beirut, following the withdrawal of the only other candidate, Henri Lopes of the Republic of the Congo. Diouf took office as Secretary-General on January 1, 2003. He was re-elected as Secretary-General for another four years at the organization's summit in Bucharest in September 2006.
Diouf is an Eminent Member of the Sergio Vieira de Mello Foundation.
He is also a member of the Fondation Chirac's honour committee, ever since the foundation was launched in 2008 by former French president Jacques Chirac in order to promote world peace and on the International Multilateral Partnership Against Cyber Threats (IMPACT) International Advisory Board.