Alfasi was born in 1013 in the central Maghreb and studied at Kairouan, then the leading centre of Jewish learning in North Africa, under Nissim ben Jacob and Hananel ben Hushiel. Kairouan sat on the route between the Babylonian academies and the Jewish communities of the west, and its scholars corresponded with the geonim. What he learned there was a Talmudic method already adapting to a world in which the academies of Iraq were in decline and authority was moving westward.
He settled at Fez and worked there for most of his life, which is where the name Alfasi, the man of Fez, comes from. The Sefer ha-Halakhot was written in Morocco, and his responsa, several hundred of which survive in Arabic and Hebrew, show him answering questions from communities across the Maghreb and al-Andalus on everything from commercial partnership to the wording of a divorce document.
Around 1088, in his seventies, he was denounced to the authorities and left for al-Andalus. He reached Cordoba and then Lucena, a town whose population was almost entirely Jewish and which had a well established academy, and he headed it until his death in 1103. His pupil Joseph ibn Migash succeeded him, and the father of Maimonides studied in that line, which is one reason Maimonides treats him as an authority rather than as a predecessor.