The Shulchan Aruch (סימן תרעט) says we should first light the Chanukah candles, and then the Shabbat candles. If one accidentally lit the Shabbat candles first, is it permissible to light Chanukah candles afterwards?
We are not referring to the wife lighting Shabbat candles before her husband lights Chanukah candles. The husband is not necessarily accepting Shabbat if his wife lit Shabbat candles,. The husband can still light Chanukah candles afterwards. Instead we are addressing the situation where the wife needs to light Chanukah candles because her husband isn't present or is unable to light them himself. If the wife lit Shabbat candles first and accepted Shabbat upon herself, can she still light Chanukah candles?
The Tur brings a disagreement between the various Rishonim:
The Bahag says that we need to light Chanukah candles prior to Shabbat candles, and If a person lit Shabbat candles first, they cannot light Chanukah candles any more since they have already accepted Shabbat upon themselves. The Tosafot say that lighting Shabbat candles does not necessarily mean that the person brought Shabbat upon themselves, so they should light Shabbat candles first, and then light Chanukah candles.
The Bach explains the Tosafot: We light Shabbat candles before Chanukah candles because of the principle of תדיר ושאינו תדיר תדיר קודם — the more frequent thing takes priority over something less frequent. Since Shabbat candles are lit on a weekly basis, they take precedence over Chanukah candles which are only lit eight days in the entire year. This is also the opinion of Rabbi Shlomo ibn Aderet and Rabbeinu Yerucham.
According to the Shulchan Aruch, we light Chanukah candles and then light Shabbat candles. The Kaf Hachaim cites the Birke Yosef that we should follow the Shulchan Aruch. This is also the opinion of the Rabbi David ibn Zimra. Furthermore, there is another reason to light Chanukah candles first. There is a concept of מעלין בקודש, increasing in holiness. It follows that we should light Chanukah candles first because Shabbat candles are holier.
There are three opinions among the Achronim.
The Levush says the wife can light Chanukah candles in all cases after lighting Shabbat candles.
The Turei Zahav says that once the wife lights Shabbat candles, she may no longer light Chanukah candles since she has accepted Shabbat by lighting the Shabbat candles, However, she can appoint another member of her household to light Chanukah candles for her.
The Magen Avraham says that the restriction on lighting Chanukah candles after Shabbat candles only applies to women because women are accustomed to accepting Shabbat by lighting Shabbat candles. Men on the other hand, do not normally bring in Shabbat by lighting Shabbat candles, so they are permitted to light Chanukah candles after lighting Shabbat candles. This is also the conclusion of the Mishna Brurah.
According to Rav Ovadia in his book Chazon Ovadia, Sephardi women do not bring in Shabbat by lighting Shabbat candles. Therefore, it is permissible for a Sephardi woman to light Chanukah candles after lighting Shabbat candles. This is the opinion we follow.