There is a widely-accepted, time-honored custom to light candle in memory of a loved one, or of a Sadik, during the Shiba mourning period, and each year on the Yahrtzeit. Although this practice is not mentioned explicitly anywhere in the Talmud, it might be alluded to in two places. First, the Gemara relates that before Rebbi (Rabbi Yehuda Ha'nasi) passed away, he gave his sons a number of instructions, one of which was that there should be a candle lit by his place. Rashi explains that Rebbi's soul returned to his home every Friday night to be with his wife, ad so he asked that there would be a candle lit by his place in honor of Shabbat. But the Yabetz (Rav Yaakob Emden, Germany, 1697-1776) suggests that this might be a basis for the custom to light a candle in honor of one's deceased parent, as Rebbi's instruction could be understood to mean that he wanted his children to light a candle in his honor. Another possible source is the Gemara's discussion in Masechet Berachot (53) of the Beracha "Boreh Me'oreh Ha'esh" recited over a flame on Mosa'eh Shabbat. The Gemara states that this Beracha may be recited only over a candle that was lit for illumination purposes, as opposed to "Ner Shel Metim" – "the candle of the deceased" – which is lit in honor of the deceased, and not for illumination. This would certainly indicate that there was a practice to light candles in honor of the deceased. However, this might refer only to candles lit around the deceased before burial, as opposed to our practice to light candles during Shiba and on the Yahrtzeit. In the writings of the Rishonim, we find mention of this concept in the Kolbo (by Rav Yehonatan of Lunel, Provence, late 13th-early 14th century), in the section discussing the laws of Yom Kippur. He writes that it is customary to light candles on Ereb Yom Kippur in memory of one's deceased parents. This custom is brought by the Rama (Rav Moshe Isserles, Cracow, 1530-1572) in his glosses to the Shulhan Aruch. The Mishna Berura (Rav Yisrael Meir Kagan of Radin, 1839-1933) writes that even the deceased are, in a sense, judged on Yom Kippur, and so we light candles in their memory as a source of merit for them. What's the explanation of this practice? How does lighting a candle benefit the soul of the deceased? One explanation is that lighting a candle in itself brings no benefit to the deceased, but when candles are lit in the synagogue, this fulfills a Misva which brings merit to the deceased's soul. Generations ago, candles were needed for illumination, and so lighting candles in the synagogue was a very important Misva. Indeed, it was customary years ago for people to donate oil for the lights in the synagogue in merit of a deceased parent. More generally, lighting candles enhances the atmosphere of the synagogue, and this, too, constitutes a Misva which brings merit to the deceased. (Interestingly, one contemporary work suggested that it would be appropriate to donate towards the synagogue's electric bill as a merit for the deceased, just as years ago people would donate oil for the lights.) According to this explanation, the value of lighting candles is only when it is done for a Misva, meaning, when the candles are lit in the synagogue. However, the Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909), in his Torah Li'shmah, writes that the lighting itself brings comfort and joy to the soul of the deceased. He explains that a soul is like a candle, and similar entities are attracted to one another. Therefore, when a candle is lit at a place where the soul is present, the soul experiences some degree of enjoyment. However, the Ben Ish Hai emphasizes that this is relevant only in the place where the soul is present – namely, in the deceased's home during the Shiba period, or at the grave. According to the Ben Ish Hai, then, there is no purpose to light a candle in memory of the deceased in his or her home after the Shiba, or even during the Shiba if the mourning is observed somewhere other than the deceased's home. Regardless, the Poskim accorded great importance to this custom. It is mentioned in the major works on mourning (Gesher Ha'haim, Ma'abar Yabok). In fact, the Mishna Berura (261) writes that during the period of Ben Ha'shemashot after sundown on Friday afternoon, when it is permissible to ask a gentile to perform a Melacha (forbidden activity) on one's behalf when there is a great need, one may ask a gentile to light a Yahrtzeit candle. Meaning, if one forgot the light the candle before Shabbat, he may ask a non-Jew to do so during the period of Ben Ha'shemashot, because this is considered a matter of great need. Likewise, Hacham Bension Abba Shaul (Israel, 1924-1998) writes that if one has Yahrtzeit on Yom Tob and forgot to light the candle before Yom Tob, he may light it on Yom Tob (from a preexisting flame). This is considered a significant enough need to permit lighting a candle on Yom Tob. When lighting the candle, the Ben Ish Hai writes, it is proper to declare that the candle is being lit for the "Menuhat Nefesh" ("rest of the soul") or "Iluy Nefesh" ("elevation of the soul") of the deceased, mentioning the deceased's name. It is also proper to give some charity at the time the candle is lit. Some opinions say it is preferable to use oil for this candle, because the word "Shemen" ("oil") has the letters of "Neshama," whereas others say wax should be used, because the letters of the word "Sha'ava" ("wax") represent the verse, "Hakisu Ve'ranenu Shocheneh Afar" – "Awaken and rejoice, those who lie in the earth," the verse which speaks of the resurrection of the dead in the future. Summary: There is a time-honored custom to light a candle in memory of a deceased loved one during the Shiba mourning period, and on the Yahrtzeit. According to one view, the candles are lit in the synagogue as a merit for the deceased, whereas others explain that a candle lit in a place where the deceased's soul is present brings joy and comfort to the soul. Therefore, according to many opinions, the candles should be lit only in the deceased's home during Shiba, at the grave, or in the synagogue.