Zahir al-Din Abu'l-Hasan Ali ibn Zayd-i Bayhaqi (Persian: ظهیرالدین ابوالحسن علی بن زید بیهقی; c. 1097 – 1169) also known as Ibn Fondoq (ابن فندق) was a polymath and historian. He is the author of Tarikh-i Bayhaq.
Bayhaqi was a descendant of Khuzaima ibn Thabit (died 657), a companion of Muhammad. Most of his forefathers were either judges or Imams.
Bayhaqi was born in Sabzevar, in northeastern Iran, the main city of the Bayhaq district, where his father’s estates were located.
In 1114, Bahyaqi along with his father visited Omar Khayyam, the famous Persian mathematician and astronomer, in Nishapur and while there Bayhaqi began his education in literature and science. He moved to Marv to complete his studies in Islamic jurisprudence by 1123. He returned to Nishapur in c.1127 where according to Yaqut al-Hamawi, his studies were "interrupted by marriage".
Bayhaqi became the qadi of Bayhaq through the efforts of his father-in-law, Shehab-al-Din Moḥammad b. Mas'ud, along with patronage from the Seljuq Sultan Sanjar. He may have made some enemies while in charge, he soon grew tired and resigned.
Bayhaqi then traveled to Ray and devoted himself to mathematics and astrology, and later studied in Nishapur to improve his understanding of astrology. While living in Sarakhs he squandered all of his money, and returned to Nishapur.
After an attempt to establish himself in Bayhaq failed "because of his relatives’ envy", Bayhaqi finally returned again to Nishapur and settled down to life in the seminary and the mosque.
In 1148, Demetrius I of Georgia presented inquiries ("of unknown purport") in Syriac and Arabic to Sultan Sanjar through an envoy. Bayhaqi was given the task of responding to Demetrius' inquiries by Sultan Sanjar.
Bayhaqi authored over 70 works ranging from Arabic grammar to astrology to philology.