Ibrahim was born in 1696, on the coast of the Red Sea, near where Ethiopia now borders Sudan. He was rumored to be the 19th son of some lesser ruler or warlord. "As the other sons were brought to their father with their hands trussed up with a rope, he enjoyed freedom of the youngest son swimming in his father's fountains" - (Pushkin's notes to Evgenij Onegin).
At the age of seven Ibrahim was taken to the court of the great sultan of Turkey at Istanbul. The German biography of Ibrahim, compiled anonymously from his own words explains that "the children of the noble families were taken to the ruler of all the muslims, Turkish sultan, as hostages", to be killed or sold to slavery if their fathers misbehaved. Ibrahim's sister Lahan was taken into captivity at the same time but killed herself during the voyage.
In 1704, after one year in the capital, Ibrahim is taken away by the deputy of the Russian ambassador, who was following the orders of his superiors. (One of whom was Petr Andreevich Tolstoj, great grandfather of the great writer Lev Tolstoy.)
All of this was done by order of Peter the Great. Apparently, Ibrahim wasn't the only "arap" boy to be taken. While it was fashionable at the time to have black children at the courts of European monarchs, this was not the main reason for the Tsar's orders. Peter was pursuing an educational goal. "Araps" were considered to be savage and uncivilized at that time, but Peter wanted to prove that these children were as good in the arts and sciences as their Russian peers were and to show that he valued people by their abilities and not their skin color.
Ibrahim was baptized in 1705, in Vilne with Peter as his godfather. In 1717, Ibrahim was taken to Paris to continue an education in the arts, sciences, and warfare. By then he was fluent in several languages and knew mathematics and geometry. He fought with the French against Spain and rose to the rank of captain. It was during his time in France that Ibrahim adopted his surname in honor of the Carthaginian general Hannibal.
Ibrahim's education was completed by 1722 and he was due to return to Russia. He wrote to Peter (already Emperor, not Tsar) and begged for permission to return to Russia by land, not sea. It is rumored that he was met on his return by Peter himself, a few kilometers away from Moscow.
After the death of Peter, Ibrahim was exiled for almost fifteen years, until Elizabeth became the new monarch. He became a prominent person in Elizabeth's court. It is rumored that the great general Aleksandr Suvorov owed his life as a soldier to Ibrahim, who convinced Suvorov's father to let his son pursue a military career.
Ibrahim married twice. His first wife was a Greek woman and the couple had one daughter. Ibrahim divorced her and married his second wife, Christina-Regina Scherberg. Ibrahim and his new wife had several children, including a son Osip. Osip in turn would have a daughter Nadezhda, who was the mother of Aleksandr Pushkin.