THE TIME TO LIGHT NER CHANUKAH [Ner Chanukah: time]
Gemara
(Mishnah): The Menorah must be inaugurated through Hadlakas ha'Neros Bein ha'Arbayim (in the afternoon).
Pesachim 59a (Beraisa #1): The Tamid is offered before the Pesach, and the Pesach precedes (lighting) the Menorah. Something (Pesach) about which it says "ba'Erev" and "Bein ha'Arbayim" is after something (the Tamid) about which it says only "Bein ha'Arbayim."
Question: If so, Ketores and the Menorah, about which it says only "Bein ha'Arbayim," should also precede the Pesach!
Answer: "Ya'aroch Oso Aharon u'Vanav me'Erev Ad Boker" teaches that the Menorah is the only Avodah (that one may begin) from night until morning.
(Beraisa #2): The Tamid is offered before the Menorah. The Menorah precedes the Pesach;
"Oso" teaches that no other Avodah inside (the Heichal) may follow the Menorah.
Shabbos 21b (Beraisa): The Mitzvah is for Ner Chanukah to burn from sunset until the last people cease from the market.
Suggestion: If it extinguished, one must relight it!
Rejection #1: No, this teaches that if one did not light at sunset, he may still light until this time.
Rejection #2: No, this teaches that one must put enough oil to burn until this time.
Rishonim
Rif and Rosh (Shabbos 9a and 2:3): The last people leave the market half an hour after Shki'ah.
Ran (DH Mitzvasah): The Gemara does not mean that one may not light before Shki'ah. Shabbos proves this. One must light before Shki'ah according to Rabah, who say that Bein ha'Shemashos begins at Shki'ah. Rather, the primary Mitzvah is at Shki'ah. One may light earlier. It seems that Bahag holds that one may not light earlier. Even on Erev Shabbos one lights after Shki'ah, according to Rav Yosef, who say that it is still day until the top of the sky darkens like the horizon.
Ran (DH d'Iy): Tosfos says that only in their days one would light only until the last people cease from the market, but nowadays that we light indoors, it is always the time. The miracle is publicized to those in the house. However, l'Chatchilah the Mitzvah is to light at Shki'ah, for zealous people do Mitzvos promptly.
Rambam (Hilchos Chanukah 4:5): We do not light Ner Chanukah before Shki'ah, rather, with Shki'ah, not before or after. If one forgot or was Mezid and did not light with Shki'ah, he lights until the last people cease from the market. This is half an hour or more. After this time, he does not light.
Rosh: If one did not light at sunset, he may still light until the last people leave the market. After this, the time ended. Even though the Gemara gave another answer, it is proper to light at the beginning of the night. It seems that we, who light indoors, and there is a Heker (it is noticeable) only to the household, need not be so particular about this. Alternatively, one must put enough oil to burn until this time. Alternatively, after this time one may extinguish it or use its light.
Tosfos (Zevachim 56a DH Minayin): For all other laws of the Torah, the day ends later, at Tzeis ha'Kochavim. Zerikah is different. It seems that Rashi holds that also here, Shki'as ha'Chamah refers to the end of Shki'ah, i.e. Tzeis ha'Kochavim.
Mordechai (Shabbos 268): If one did not light Ner Chanukah at night, he does not light (afterwards). The Mitzvah was lost. The Beraisa says that the Mitzvah is from sunset until the last people cease from the market. If one did not light (at sunset), he lights (until this time). This connotes that if so, he did not do the ideal Mitzvah. During the day, publicity of the miracle is not evident. All the more so he does not light (to compensate) on another night. .
Rashba (Shabbos 21b DH Ha): Presumably, there is no problem lighting shortly before Shki'ah. It publicizes the miracle. We say (23b) that the fire (that accompanied Bnei Yisrael in the Midbar) came during the day, before the cloud departed. Lighting shortly before Shabbos shows that it is for the sake of Shabbos; the same applies here. In practice, we hold like Rabah, and according to him one must light Ner Chanukah before Shki'ah on Erev Shabbos.
Poskim
Shulchan Aruch (OC 672:1): We do not light Ner Chanukah before Shki'ah, rather, at the end of Shki'ah.
Bach (DH Mitzvasah): The Mordechai explains that we discuss the end of Shki'ah, for a Ner during the day is useless. The Ri says that from Shki'ah until Tzeis ha'Kochavim is the time to walk four Mil (72 or 90 minutes). This is like R. Tam, who says that Shki'as ha'Chamah is before 'mishe'Tishka'. The Re'em says that 'mishe'Tishka' connotes earlier, before it sets. The same applies to Ner Chanukah. Sefer Yere'im (Shabbos 274) says that Ner Chanukah is mishe'Tishka, while a little time remains in the day. However, most Gedolim hold like R. Tam, including the Terumas ha'Deshen. The Rosh says that one should be stringent to light at the beginning of the night. 'Night' refers to Tzeis ha'Kochavim, like it says in Berachos (2b). This shows that one should not light before Tzeis ha'Kochavim. This is only l'Chatchilah.
Magen Avraham (1): The end of Shki'ah is Tzeis ha'Kochavim. Maseches Sofrim (20:4) says that the Mitzvah is to light after Shki'ah. If one lit during the day we do not benefit from it and do not bless on it, for it was taught (regarding Havdalah) that one may not bless on a Ner until one benefits (from its light).
Gra (DH Sof): Also the Rosh (Ta'anis 1:12) said regarding Ta'anis (that 'Shak'ah Alav Chamah' is the end of Shki'ah, i.e. Tzeis ha'Kochavim).
Mishnah Berurah (1): We light at the end of Shki'ah, i.e. Tzeis ha'Kochavim, for this is when people pass by and see it, and this publicizes the miracle. The Shulchan Aruch wrote Stam like the Tur, but many Rishonim hold that the Gemara discusses the beginning of Shki'ah, which is about 15 minutes earlier. People who normally pray Ma'ariv in the proper time, i.e. after Tzeis ha'Kochavim, should light before Ma'ariv. The Gra did so. If Tzeis ha'Kochavim came, he should pray first, for this is Tadir (more frequent), and it includes Kri'as Shma, which is mid'Oraisa. Even those who light after Ma'ariv should prepare the Neros beforehand. If they will start to prepare after Ma'ariv, surely there is concern lest the primary time pass, i.e. half an hour.
Kaf ha'Chayim (2): One should not light Bein ha'Shemashos. We do not say that one may be lenient about a Safek mid'Rabanan. If Tzeis ha'Kochavim came, he should light promptly.
Kaf ha'Chayim (5): Shevus Yakov says that it is best to light after Ma'ariv, for Ma'ariv is Tadir. Machazik Berachah says that one who lights before Ma'ariv does not lose, for after Ma'ariv perhaps the time will expire before he lights. I say that when there is no such concern, he should light afterwards, especially nowadays that we light indoors and there is no Heker for people in Reshus ha'Rabim.
Shulchan Aruch (ibid.): We do not light before or after this.
Beis Yosef (DH v'Ha d'Tanya): The Rambam holds like Bahag, that one may not light before Shki'ah. The Tur mentioned that we light at the end of Shki'ah, because the beginning of Shki'ah is still day, like Tosfos (Shabbos 35a DH Trei) says.
Shulchan Aruch (ibid.): Some say that if one is busy, he may light earlier, from Plag ha'Minchah (one and a quarter hours before the end of the day), as long as he puts enough oil to burn until the last people cease from the market.
Beis Yosef (DH v'Chasuv b'Shem): Mahari Avuhav cites Orchos Chayim to say that if one lit during the day because he was busy, if it was from Plag ha'Minchah and onwards, he was Yotzei. This is no more stringent than Havdalah. One may pray Ma'ariv of Motza'i Shabbos on Shabbos (and say Havdalah over wine - Berachos 27b).
Bach (DH Mitzvasah): If one lit after Plag ha'Minchah, he was Yotzei b'Di'eved. The Shali'ach Tzibur lights in the Beis ha'Keneses when much time remains in the day. When it is impossible (to light later), this is like b'Di'eved. Likewise, everyone must light before Tzeis ha'Kochavim on Erev Shabbos. We rely on Re'em in pressed circumstances.
Kaf ha'Chayim (10): One who lights before Shki'ah does not bless.
Kaf ha'Chayim (11): If one lit before Plag ha'Minchah, he extinguishes it and lights it again.
Birkei Yosef (2): On Erev Shabbos one should pray Minchah before lighting Ner Chanukah. Minchah corresponds to the afternoon Tamid, and Ner Chanukah commemorates the Nes with the Menorah, which was lit after the afternoon Tamid.
Shulchan Aruch (2): If one forgot or was Mezid and did not light at Shki'ah, he lights until the last people cease from the market, which is about half an hour. Then people pass by, and there is publicity of the miracle.
Beis Yosef (DH vea'Ha d'Amrinan): The Rosh connotes that if one did not light within the time, it is a Safek, and he lights.
Rema: Some say that nowadays that we light indoors, one need not light before the last people cease from the market.
Magen Avraham (5): He lights at night, and his household gathers together. It is good to light before eating. Maharshal forbids even learning once the time came. Even if he began, he interrupts, like we say (about Bedikas Chametz) in OC 431:2). I say that if he did not pray yet, he lights first, for it does not take so much time. We are not concerned lest he forget to pray Ma'ariv.
Mishnah Berurah (10): Even learning is forbidden once the time came, and all the more so eating or other matters.
Bi'ur Halachah (DH umi'Kol): Even though we light inside (one should light in the proper time), since we light in the doorway and it is open, so there is a Heker for people passing by.
Sha'ar ha'Tziyon (14): According to the opinion that one lights after Tzeis ha'Kochavim, in any case eating and other matters are forbidden half an hour beforehand, due to Kri'as Shma. Those who light at Shki'ah should be stringent half an hour beforehand, but regarding learning, one may rely on the opinion that one lights after Tzeis ha'Kochavim, and learn until then.
Shulchan Aruch (ibid.): This is l'Chatchilah. If the time passed and he did not light, he lights at any time during the night.
Magen Avraham (6): The Beis Yosef connotes that it is a Safek. If so, he does not bless. The Shulchan Aruch connotes that he blesses. The Maharshal says that he blesses until midnight, but not afterwards. Hagahos Maimoniyos says that one may bless as long as the household is awake, even until dawn. If they are sleeping, he should not bless.
Mishnah Berurah (11): Just like in the days of the Gemara they would bless only at a time that publicizes the miracle, also we bless only if the household is awake. If one came home before dawn and the household was sleeping, it is proper to wake them, in order to light with a Berachah.
Kaf ha'Chayim (26): If the household are sleeping, some say that it suffices to wake two of them (and light with a Berachah).
Bi'ur Halachah (DH Lo): If one always prays Ma'ariv in the proper time, he should light Ner Chanukah beforehand. Firstly, the Gra brings many Rishonim who say to do so l'Chatchilah. Even the Tur, who says that one should light at Tzeis ha'Kochavim, permits lighting almost half an hour beforehand. Further, the Rambam holds that the Mitzvah is only half an hour. He says to light 'with Shki'ah.' If this means when the sun is covered from our eyes, if one lights after Tzeis ha'Kochavim, he lost the Mitzvah! Even those who permit lighting after the time say so only due to Safek.