Avempace was of Arab descent. He was born in Zaragoza, in what is today Aragon, Spain, around 1085 and died in Fes then under the Almoravid dynasty, in 1138. Rulers of Zaragoza shifted constantly throughout Avempace's young life, but in 1114, a new Almoravid governor of Zaragoza was appointed: Abu Bakr 'Ali ibn Ibrahim as-Sahrawi, also known as Ibn Tifilwit. The close relationship between Avempace and Ibn Tifilwit is verified in writings by Ibn al-Khatib. Avempace enjoyed music and wine with the governor and also composed panegyrics and muwashshahat to publicly praise Ibn Tifilwit, who rewarded him by nominating him as his vizier. In a diplomatic mission to meet the overthrown Imad ad-Dawla Ibn Hud King in his castle, Avempace was placed in jail for some months for reasons unknown. Ibn Tifilwit was also killed during a quest against the Christians in 1116, ending his short reign and inspiring Avempace to compose mournful elegies in his honor. Avempace also had a talent for singing and composition in music. In the beginning of his career, he wrote the manuscript Risālah fī l-alḥān (Tract on melodies) and incorporated his commentary on al-Fārābī’s treatise based on music. He determined the correlations between different melodies and temperament. According to biographer al-Maqqarī, Avempace's passion for music was due to poetry and had “the virtue of dispelling the sadness and pain of the hearts [sic].” He included his scientific knowledge and wit in many poems. Avempace joined in poetic competitions with the poet al-Tutili.