As we have seen, the Sages ordained that one must light the Ĥanuka candles after sunset. If people were to light earlier, the sunlight would render the candles less visible. However, on Friday evening, obviously one may not light candles after sunset, since Shabbat begins at sunset, and on Shabbat one may not light a fire. In addition, one should not light immediately before sunset because of the mitzva of tosefet Shabbat, which dictates that we begin Shabbat a bit early in order to extend the sanctity of Shabbat into the mundane week. In practice, most Israeli communities accept Shabbat about twenty minutes before sunset, and, accordingly, this is the Shabbat candle-lighting time that appears on Israeli calendars. On Shabbat Ĥanuka, one must light the Ĥanuka candles before lighting the Shabbat candles.
Although we light Ĥanuka candles before sunset on Friday, the primary time for publicizing the miracle is at night. Therefore, one must make sure that there is sufficient wax or oil for the candles to remain lit until half an hour after tzeit.
It is preferable to pray Minĥa with a minyan before lighting the Ĥanuka candles, because Minĥa relates to the outgoing day, whereas the candles are part of the upcoming day. However, one should not skip Minĥa with a minyan to this end (sa 679:1; mb ad loc. 2; Kaf Ha-ĥayim 671:79).
On Motza’ei Shabbat, one must first pray Ma’ariv and then light candles. Many people also make havdala before lighting, because havdala concludes Shabbat, whereas the candles belong to the upcoming day (Taz 681:1; ahs 681:2; Ben Ish Ĥai, Year 1, Hilkhot Ĥanuka 21 [Vayeshev]). Others light Ĥanuka candles before havdala, in order to light as soon as possible after tzeit. Additionally, one should delay havdala as much as possible in order to extend the sanctity of Shabbat to some extent. Nevertheless, in order for lighting candles to be permissible before havdala, one must first recite either Ata Ĥonantanu during the Amida of Ma’ariv or the phrase “barukh ha-mavdil bein kodesh le-ĥol” (“blessed is the One Who distinguishes between the sacred and the mundane”) (sa and Rema 681:1). In practice, both customs are halakhically valid (bhl ad loc.), and each person may choose his own custom.