Alexander Kazembek's father, Hadji Kasim Kazem-Bey, was a prominent Azerbaijani Muslim cleric and a native of the city of Derbent (then part of the Quba Khanate, Qajar Persia, later part of Russia), whose father (Alexander Kazembek's paternal grandfather) Nazir Muhammad khan was paymaster general of the Derbent Khanate. On his way back from a religious pilgrimage to Mecca, Muhammad Qasim Kazim-bey visited Rasht (present-day Gilan province, Iran) and met a woman named Sharafnisa, daughter of the local governor Bagher-khan. The two married and settled in Rasht, where Kazembek was born. In 1811, his father was appointed qadhi in Derbent, and the family moved there. Kazembek completed his studies in Islam and, already fluent in Azeri and Persian, also excelled in Russian, Turkish and Arabic. At the age of 17, he wrote his first book named Topics in Grammar of the Arabic Language (originally in Arabic). His father wanted him to become a Muslim scholar and was going to send him away to Persia and Arabia to master Islamic studies. However, in 1820, Muhammad Qasim Kazim-bey was charged with espionage on behalf of Persia, deprived of his religious title and exiled to Astrakhan along with his wife.