The first black presidents in the world were Alexandre Sabès Pétion and Henry Christophe. They both ran for President of the newly-independent State of Haiti, which fractured the nation. A more stable position of President would be President of Liberia, occupied by Joseph Jenkins Roberts and subsequently Stephen Allen Benson.
The first African-American President was not the President of the USA, nor South Africa. Haiti had a black President in office long before Barack Obama. Haiti was a tumultuous state surrounding the declaration of its independence from France. The French colony, called Saint-Domingue, declared its independence in 1904 after a thirteen-year-long Haitian Revolution. The sovereign state of Haiti strove to eliminate slavery and colonial rule. Its first ruler was Governor-General for Life Toussaint Louverture. He did not sever ties with France, but he wrote the first Constitution against Napoleon’s will. Jean-Jacques Dessalines betrayed him, and Louverture died in prison. Dessalines then beat the French and declared Haiti to be an independent nation, becoming its first emperor and passing the second Constitution in 1805. In 1806, however, he was assassinated, so Henry Christophe was appointed a dictator by the military council. However, he participated in a democratic election against another prominent revolutionary, Alexandre Sabès Pétion, and lost. After a brief military conflict, Christophe ran to northern Haiti and declared himself President of the splintered state. He later crowned himself King, while Pétion ruled over the rest of Haiti, struggling against inflation, the rogue Henry I, and dissident generals. Both could be considered the first black President in the world.
Liberia had a less tumultuous and longer-lived presidency. Joseph Jenkins Roberts was a free-born African-American merchant who came to Liberia in 1829 from the United States. He was elected President after Liberia declared independence in 1847. He was succeeded in 1856 by his also free-born African-American Vice-President Stephen Allen Benson, who had lived in Liberia since childhood. Liberia did not fare particularly well under him, but there were no disastrous military coups, and the institute of Liberian presidency worked much better than that of Haiti. Roberts would be re-elected as the seventh President of Liberia in 1872.