It is forbidden on Shabbat to ask a non-Jew to perform an action which is forbidden for Jews. Some Halachic authorities maintain that this is forbidden on the level of Torah law, but the accepted view is that this prohibition was enacted by the Sages.
The Ba’al Ha’itur (Rav Yishak of Marseilles, 1122-1193) maintained that this prohibition does not apply in situations where a Melacha is necessary for the purpose of a Misva. For example, if the synagogue is dark, and the congregants cannot pray, learn or read the Torah, then, according to the Ba’al Ha’itur, it would be permissible to ask a non-Jew to kindle a light to enable the people to use the synagogue. Since this is needed for the sake of a Misva, it is permissible.
However, the vast majority of Rishonim (Medieval Halachic authorities) disputed this ruling. According to the accepted view, it is permissible for the sake of facilitating a Misva only to ask a non-Jew to perform an action that is forbidden Mi’de’rabbanan – by force of Rabbinic enactment. When it comes to Torah prohibitions, however, such as kindling a flame, it is forbidden to ask a non-Jew to perform such an action on Shabbat, even for the sake of facilitating a Misva. This is, indeed, the ruling of the Shulhan Aruch.
With regard to our synagogues today, Hacham Ovadia Yosef ruled that under extenuating circumstances, such as if a Minyan assembled in the synagogue and they cannot pray because the lights are off, there is room to allow asking a non-Jew to turn on the lights on. Some Halachic authorities maintain that turning on electric lights is not equivalent to kindling a flame, and is forbidden on Shabbat only Mi’de’rabbanan. These authorities argue that since the Shabbat prohibitions are modeled after the activities performed during the Mishkan’s construction, turning on electric lights cannot be forbidden on the level of Torah law, as electric lights obviously did not exist at that time. (Other authorities distinguish between different kinds of electric lights, and maintain that some may not be turned on the level of Torah law, while others are forbidden Mi’de’rabbanan.) According to this view, it is permissible to ask a non-Jew to turn on an electric light for the sake of facilitating a Misva. Hacham Ovadia rules that in situations of great need, one may rely on this opinion, especially in light of the fact that the Ba’al Ha’itur permits asking a non-Jew to perform even a Melacha forbidden by Torah law, if this is necessary for a Misva.
It must be emphasized, however, that Hacham Ovadia issued this ruling only for situations where the need arises, but not as a matter of policy. Synagogues should rely on this ruling only in situations where the timers malfunctioned or some other unusual circumstance arose that resulted in the synagogue being dark. As a matter of policy, however, synagogues should either leave the lights on throughout the entirety of Shabbat or set them on timers, so they do not have to rely on a non-Jew. (This is the ruling of Hacham David Yosef, in his work on Amira Le’akum.)
It should be noted that there is greater room for leniency during the day, if there is sunlight entering the synagogue through the windows that makes it possible to read, albeit with some difficulty. If there is sufficient light to allow for reading in the synagogue, then one may indirectly ask a non-Jew to turn on the lights to make reading easier. For example, one may say, "It’s a bit dark in here," or something to that effect, without explicitly asking the non-Jew to turn on the lights. This is the ruling of the Mishna Berura (307:76). However, if the synagogue is dark, such as when people come early Shabbat morning for Bakashot in the wintertime, and one cannot read at all in the synagogue, a non-Jew may be asked to turn on the lights only in situations of need, but this should not become the standard practice.
If the electricity in one’s home went out on Friday night due to a blown fuse, and a non-Jew – such as a housekeeper – voluntarily goes to the circuit breaker and turns on the electricity for the family, they may not use the lights in the home for activities that could not be done in the dark. However, if the Shabbat candles were burning in the dining room at the time, then it would be permissible to use the electric lights in the dining room. Since it was possible even when the power was out to read and perform other activities in the dining room – albeit with some difficulty – and by restoring the power the non-Jew merely enhanced the lighting in that room, the additional light may be used. In fact, as noted above, it would be permissible to indirectly ask a non-Jew to restore the power in order to provide more light in the dining room. The lights in the other rooms of the home, however, may not be used for reading and the like, because the light was provided by a non-Jew specifically for a Jew on Shabbat.
Hacham Ovadia Yosef rules that in such a case, when a non-Jew restored the power after a blown fuse on Shabbat, one may use the hotplate, despite the fact that it was turned on by a non-Jew for a Jew on Shabbat. He explains that when the non-Jew turned on the circuit breaker, his intent was to restore the lighting in the house; he was not thinking about the hotplate. Therefore, although his action inevitably turns on the hotplate, the Jew may derive benefit from the hotplate on Shabbat. This is also the ruling of Rav Yosef Shalom Elyashiv (Israel, 1910-2012).
There is a debate among the Halachic authorities as to whether one may learn Torah in a room where the light was turned on by a non-Jew for a Jew on Shabbat. Some Poskim maintain that since "Misvot Lav Le’hanot Nitenu" – we perform Misvot to serve G-d, and not for personal benefit – studying Torah does not constitute "benefiting" from light. Others (such as the Be’ur Halacha) disagree, and maintain that one may not even learn Torah by the light turned on by a non-Jew for a Jew on Shabbat. Hacham Ovadia Yosef, in Hazon Ovadia – Shabbat (vol. 3), follows the lenient position, and allows learning Torah in the lit room in such a case.
Summary: Synagogues should ensure to either leave the lights on throughout Shabbat, or set them on timers, rather than ask a non-Jew to turn the lights on in the morning. If it happens that, for whatever reason, the lights in the synagogue are turned off, one may ask a non-Jew to turn them on to allow the congregation to pray and study, but this should not be the standard practice. If the power goes out in one’s home and a non-Jew goes to the circuit breaker and restores electricity for the family, they may not use the light to perform activities which could not be done in the dark (such as reading). However, they may make use of the light in the rooms which were somewhat illuminated even when the power was out, such as by the light of the Shabbat candles. They may also use the hotplate. If a non-Jew turned the lights on in a dark room for a Jew on Shabbat, even though it is forbidden to benefit from the light, he may learn Torah in the room.