The Poskim discuss at length whether the Arvit prayer should be recited before lighting Chanukah candles or vice versa.
Until Pedestrian Traffic Ceases
Let us explain the root of the disagreement: The Gemara (Shabbar 21b) quotes a Baraita (Tannaic teaching) which states that the proper time to light Chanukah candles is from nightfall until pedestrian traffic ceases from the street. The time between nightfall and this time is a half-hour.
The Gemara explains two novel Halachot that arise from this Baraita. One is that if one has not yet lit at nightfall, one should still light within the half-hour before pedestrian traffic ceases. The second idea is that the amount of oil one must fill the candles with is equal to the amount of time between nightfall and the time when pedestrian traffic ceases from the street, which is equal to a half-hour of burning time.
The Opinion of Several Rishonim
According to some Rishonim, these answers in the Gemara disagree with one another and therefore, according to the first answer, if one has not lit by the time pedestrian traffic has ceased, i.e., a half-hour past nightfall, the Mitzvah to light no longer applies after this point. Indeed, the Rambam is of the opinion that once half-hour after nightfall arrives, one can no longer fulfill the Mitzvah of lighting Chanukah candles.
The Rashba’s Opinion
On the other hand, the Rashba and other great Rishonim explain that the two answers of the Gemara are not mutually exclusive and both ideas are true: One should preferably light before a half-hour past nightfall elapses and one must also fill the candles with at least a half-hour’s worth of oil. However, even if one misses the above time, such as if one arrives home at 11:00 pm, one must still light Chanukah candles and is merely considered not to have fulfilled the edict of the Sages in the most preferred manner, for ab initio, one should strive to light at nightfall or, at least, within the half-hour past nightfall.
The Opinion of Maran Ha’Shulchan Aruch
Maran Ha’Shulchan Aruch (Ch. 672) rules in accordance with the Rashba’s opinion that one should preferably light Chanukah candles at nightfall, neither before nor after, however, if one arrives home late at night, one must still light Chanukah candles. The Magen Avraham explains that Maran means that one must likewise recite a blessing on this lighting.
Frequency vs. Publicization of the Miracle
Based on the above, the Poskim discuss whether the Arvit prayer should be recited before or after lighting Chanukah candles. We have a rule in the Talmud that when one is faced with two different Mitzvot to perform, one should perform the more frequent of the two and only then perform the other. Thus, since Arvit is more frequent, as it is recited every night of the year while Chanukah candles are only lit eight nights of the year, Arvit should be recited before Chanukah candles are lit.
Although Hagaon Harav Chaim Benbenisti writes in his Sefer Shiyarei Kenesset Ha’Gedolah that he would customarily pray Arvit before lighting Chanukah candles, it is possible he meant this when one prays Arvit before nightfall. However, if one arrives home at or after nightfall, one should leave the house to pray Arvit and then light Chanukah candles afterwards, for Maran rules that one should light “neither before nor after nightfall” and one should strive to light as close as possible to nightfall, within a minute or two, for this causes a greater publicization of the miracle.
Although lighting Chanukah candles is not as frequent a Mitzvah as the Arvit prayer, Tosafot (Megillah 3a) explain that if a Mitzvah containing publicization of a miracle cannot be performed optimally if another more frequent Mitzvah were to be performed before it, the Mitzvah containing a publicization of the miracle takes precedence.
The Bottom Line
Halachically speaking, although one should certainly try to follow the ancient Sephardic custom of praying Arvit with the congregation prior to nightfall and then going home to light Chanukah candles at nightfall, if one did not have a chance to do so and arrives home at nightfall, one should light Chanukah candles immediately and only then leave the house to go pray Arvit in the synagogue. Indeed, Maran zt”l rules likewise in his Sefer Taba’at Ha’Melech (commentary on Rambam, Ch. 4 of Hilchot Chanukah).
However, one who arrives home at a late hour of the night and has already missed the opportunity to light within a half-hour of nightfall should see to it to pray Arvit prior to lighting Chanukah candles, for there is no halachic difference between lighting at 10:00 pm vs. 11:00 pm. Thus, one should pray Arvit first since this is the more frequent of the two Mitzvot and it also contains within it Keri’at Shema, which is a Torah commandment. Maran zt”l rules likewise in his Chazon Ovadia- Chanukah.
Summary: One should preferably light Chanukah candles at nightfall or, at the very least, within the half-hour that follows. If one misses the opportunity to light by this time, one must light anytime for the duration of the night (until dawn). One should likewise pray Arvit before nightfall so that one can return home and light Chanukah candles at nightfall. One who has not yet had a chance to pray and arrives home at nightfall should first light Chanukah candles and only then go to pray. However, if one will arrive home past the initial half-hour after nightfall, one should first pray Arvit and only then return home and light Chanukah candles.