Hacham Haim Ben Attar, known as the Or Haim, or the Or Haim HaKadosh, was born in 1696 in Salé, Morocco. The son of Hacham Moshe, he was named after his grandfather, from whom he first learned Torah. In 1705, the family was forced to flee Salé for Meknès, where they lived in Hacham Moshe De Avila’s home, with whom he studied Torah and also learned the jewelry craft.
He was married to Patsonia, his first wife, who wore a Tallit and Tefillin, at the age of 11. After a year's time, his family returned to Salé, while he remained in Meknès under the auspices of his father-in-law, Rabbi Moshe. In 1725 his father-in-law died, and he returned to Salé. He continued to travel between the cities of Morocco and, upon reaching Fes, was appointed Rosh Yeshiva by Hacham Shmuel Elbaz. Since he had had no children, he married Esther, daughter of Rabbi Meir of Fes, and the couple had several daughters.
In 1738, Morocco suffered a harsh famine and Hacham Haim Ben Attar continued his wanderings, reaching Algiers and then Livorno, Italy. In Livorno he organized a group movement to immigrate to the Land of Israel.
In 1741 Hacham Haim Ben Attar immigrated to the Land of Israel with 30 of his students, arriving to the port of Acre, where they settled. While in the Galilee Hacham Haim Ben Attar made pilgrimages to tombs of tsaddikim and to other holy places in the Galilee. He recounts the story of his travels in his book, Eretz HaHaim, which also contains a reply to a halakhic question and a missive he sent to the townspeople of Fes while he was still in Salé.
In 1742, Hacham Haim Ben Attar and his students arrived in Jerusalem, where he founded two yeshivot, one for “revealed” Torah and one for mysticism. Hacham Haim Ben Attar's arrival to the Land of Israel greatly contributed to the welfare and strengthening of the Jewish colony. He maintained contact with other sages living there, including Hacham Haim Aboulafia.
Hacham Haim Ben Attar wrote comprehensive works on diverse issues. His book Hafetz Hashem, which contains original commentary on the Talmud, was printed in 1732; two of his books, Pri To'ar - on the Shulchan Aruch and Or HaHaim – his commentary on the Five Books of Moses were printed in Livorno. His work Or HaHaim became particularly popular among Hassidim, who added HaKadosh (the saintly) to its title. He is also the author of Rishon LeZion, a book of commentary on the books of Prophets and Writings.
Hacham Haim Ben Attar passed away at the age of 47, on 15 Tammuz, 5503 (1743) and was buried on the Mount of Olives.