Framed as a dialog between the king of the Khazars, a Central Asian kingdom, and a Rabbi, the Khazari is an exposition of late medieval Jewish philosophy. Legend has it that the king of the Khazars held a symposium to decide whether his people should convert to Judaism, Christianity or Islam. This book is a fictional account of the Jewish side of this debate.
Judah Ha-Levi, the author, was born about 1080 C.E. in Muslim-controlled area of southern Spain. This was a bright spot in the history of Jewish-Muslim relations, when Jewish communities prospered under a tolerant Islamic state, and scholarship flourished. He studied the Talmud and Kabbalah, wrote secular poetry, and was fluent both in Hebrew and Arabic. (This work was originally written in Arabic). Midlife he had an awakening which led him to write on more spiritual themes, and the resulting body of work is considered some of the best post-Biblical Jewish poetry.
Conflict was increasing between the Muslims in the south of Spain and the Christians in the north, with the line moving back and forth. As the Christians advanced, Jewish communities came under pressure to convert in order to survive. Later in his life Ha-Levi ended up in Christian Toledo, where his outlook understandably took a pessimistic turn. The Kitab al Khazari (written circa 1120 to 1140) is a product of that period. It is a defense of the Jewish religion and people, with a unique philosophical underpinning based on Ha-Levi's studies and views.
As for the Khazars, the legend wraps up with them converting to Judaism based on the Rabbi's presentation. This legend has a factual basis: the Khazar state was a Turkic kingdom between the Black and Caspian seas, which existed from the seventh to the tenth century. Judaism was the state religion from about 830 on, and other religions, including Christianity, Islam, Zoroastrianism, Turkic Shamanism, and Norse and Slavic paganism were treated with exceptional tolerance. It seems likely that Ha-Levi used the Khazars as a setting for his treatise to show that there was still hope for religious tolerance amidst the Iberian culture wars.