Gilani spent his early life in Gilan, the town of his birth. In 1095, at the age of eighteen years, he went to Baghdad. There, he pursued the study of Hanbali law under Abu Saeed Mubarak Makhzoomi and ibn Aqil. He was given lessons on Hadith by Abu Muhammad Ja'far al-Sarraj. His Sufi spiritual instructor was Abu'l-Khair Hammad ibn Muslim al-Dabbas. (A detailed description of his various teachers and subjects are included below). After completing his education, Gilani left Baghdad. He spent twenty-five years as a reclusive wanderer in the desert regions of Iraq.