Shabbat candles must be lit by (and preferably 18 minutes before) sunset. Once it is twilight, the time between sunset and nightfall known as bein hashmashot, it is too late to light. Bein hashmashot begins when the sun sets below the horizon and is no longer visible.
According to Rabbi Yehuda in Tractate Shabbat, bein hashmashot lasts 13 and a half minutes. In Tractate Pesachim, however, the same Rabbi Yehuda maintains that bein hashmashot lasts 72 minutes.
In explaining the discrepancy between the duration of bein hashmashot according to Rabbi Yehuda in Shabbat and Rabbi Yehuda in Pesachim, Rabbeinu Tam explains that there are two separate sunsets: Sunset I, which begins immediately after the sun has sunk below the horizon and lasts 58 and a half minutes, and Sunset II, which starts thereafter when light begins to fade into darkness and lasts an additional 13 and a half minutes until nightfall.
According to Rabbeinu Tam, the period on Friday between Sunset I and Sunset II (58 and a half minutes) is considered weekday, during which time all weekday work may be performed and one may light candles until Sunset II, i.e. 58 and a half minutes after Sunset I.
Many Rishonim, such as the Rambam and the Gaonim, disagree with Rabbeinu Tam. They maintain that for candle lighting there is only one relevant sunset, i.e. Sunset I, when the sun dips below the horizon, and candles must be lit before such time.
Though the Shulchan Aruch agrees with Rabbeinu Tam and maintains that candles can be lit as late as 58 and a half minutes after Sunset I, the Vilna Gaon, following the opinion of the majority of the Rishonim, disagrees with the Schulchan Aruch and maintains that candles must be lit by Sunset I.
There is a third opinion, that of Rabbi Eliezer of Metz, according to which bein hashmashot begins 13 and a half minutes before Sunset I. In his view, candle lighting time would be 13 and a half minutes before Sunset I.
It should be noted that the 13-and-a-half-minute period is derived from the time it takes a person to walk 3/4 of a mile. According to most opinions, it takes a person 18 minutes to walk the distance of one mile (in which case 3/4 of a mile would take 13 and a half minutes) but according to a stricter opinion, it takes a person 24 minutes to walk one mile (in which case 3/4 of a mile would take 18 minutes).
In view of the fact that we are dealing here with the possible violation of a biblical melachah, all modern poskim agree that one must adopt the strictest of all approaches, namely that of Rabbi Eliezer of Metz and that of those who say it takes 24 minutes to walk a mile. Therefore, we light candles 18 minutes before Sunset I. To know when this is, one should consult a local newspaper or a reputable Jewish calendar.
Rabbi Moshe Feinstein writes that during the 18-minute period between candle lighting and Sunset I, members of the household that are not responsible for lighting the Shabbat candles may continue with weekday work until Sunset I, but that this should not be encouraged.
On the first night of Yom Tov – except for Shavuot – candles may be lit either at the same time as on Erev Shabbat or after returning from Maariv, provided one lights from an existing light. On the second night of Yom Tov, however, as well as whenever Shabbat precedes Yom Tov and on both days of Shavuot, candles should be lit from an existing light, after nightfall.
Raphael Grunfeld’s book, “Ner Eyal on Seder Moed” (distributed by Mesorah) is available at OU.org and your local Jewish bookstore. He can be contacted at email@example.com.