Hakim Sanai was one of the famous and great classical Sufi authors of the eleventh century. Very little is known so far about the life and works of this great philosopher and there is also confusion about the exact timeline of Hakim Sanai`s living. However, though not supported by all, many scholars say that Hakim Sanai lived between the years of 1044-1150. Hakim Sanai was born in the province of Ghazna in southern Afghanistan and hence, he was also popularly known as Sanai of Ghazna. One of the earlier Sufi philosophers, Sanai influenced a number of other Sufi philosophers in the following centuries. Jalaludin Rumi was one of those, influenced by Sanai and he acknowledged both Sanai and Attar as his two primary inspirations.
Hakim Sanai was actually a court poet and he was also engaged in writing praises for the Sultan of Ghazna. However, Hakim Sanai left his job as the court poet at a young age and started to study and know about Sufism from a Sufi master named Yusef Hamdani. He also went on pilgrimage to the holy place of Mecca and after returning from the pilgrimage, he composed one of his best works, named "Hadiqatu`l Haqiqat" or "The Walled Garden of Truth". Hakim Sanai is considered as the earliest Afghan teacher, who used the love-motif in Sufism. Sanai has composed his popular work, "The Walled Garden of Truth" in such a way that gives several readings for many passages. The book contains 10,000 couplets in 10 sections and describes Hakim Sanai`s ideas on God, love, philosophy and reason.
"The Walled Garden of Truth" earned popularity among the people during Hakim Sanai`s time and even after 900 years the book is still popular even today. The book has also been constantly employed as a classic and Sufi textbook during these years. Sanai followed the path of poetry for spreading his knowledge and message among the common people. According to him, lust and greed and emotional excitement, always stood between humankind and divine knowledge that was the only true reality (Haqq). He said that Love (Ishq) and a social conscience are the foundation of religion. He felt that the mankind is asleep and living in what is in fact a desolate world. About common religion, Sanai said that it is only habit and ritual.
Hakim Sanai had a great influence on the Persian literature through his brilliant poetry and he is considered to be the first poet to use verse forms as the qasidah (ode). He also used the verse forms as the ghazal (lyric) and the masnavi (rhymed couplet) for expressing the philosophical, mystical, and ethical ideas of Sufism. The Dervish Songs of Hakim Sanai nicely represents the lyrical presentation of Sufi experience. Talking about the progress of human being, Hakim Sanai said that the human`s progress is that of one who has been given a sealed book, written before he was born. Sanai said that the person always carries it inside himself until he `dies`. Sanai further said that man does not know the contents of that sealed book, as he is subject to the movement of Time. Hakim Sanai felt that what appears to be truth is in fact a worldly distortion of objective truth. He said that the essence of truth is far superior to the terminology of `How?` or `Why?` Sanai told his disciples that the man usually does not notice the fact that he is like an infant in the hands of a nurse. Sometimes he feels happy, sometimes sad, according to what happens to him. Hakim Sanai further asked his disciples and the common people to not to speak of their heartache and the God is speaking. Sanai suggested people not to seek God, as He is seeking. He further said that the God has actually shown everyone, the Path of the Teaching.