THE HETER TO WEAR TEFILIN AT NIGHT IN ORDER TO GUARD THEM [Tefilin :night: Shemirah]
Gemara
(Beraisa): If a Korban Pesach was slaughtered not at the proper time, Lishmah it is Pasul, and Lo Lishmah it is Kosher (but he was not Yotzei).
Menachos 36a (Beraisa): One blesses on Tefilin from the time to wear them. If one had to start traveling early, and for the safety of the Tefilin he must wear them, he wears them. When the proper time comes, he touches them and blesses.
(Beraisa - R. Yosi ha'Galili): "V'Shamarta Es ha'Chukah ha'Zos l'Mo'adah mi'Yamim Yamimah." 'Yamim' excludes nights. "Mi'Yamim" excludes some days, i.e. Shabbos and Yom Tov.
R. Akiva says, the 'Chok' referred to is Pesach (which was discussed before Tefilin).
R. Akiva learns from another source that the Mitzvah does not apply on Shabbos.
(Beraisa - R. Akiva) Suggestion: Perhaps a person should wear Tefilin on Shabbos and Yom Tov!
Rejection: "V'Hayah l'Os Al Yadcha..." - the Mitzvah applies only on days when Yisrael need an Os (sign of their closeness to Hash-m), but not Shabbos or Yom Tov, which are themselves signs.
(R. Elazar): One who wears Tefilin at night transgresses an Aseh;
(R. Yochanan): He transgresses a Lav.
R. Elazar holds that when it says "Hishamer" regarding a Lav, this is a Lav. "Hishamer" regarding an Aseh is an Aseh. R. Yochanan holds that in both cases it is a Lav.
(R. Elazar): One may wear Tefilin at night in order to guard them.
Ravina: I saw Rav Ashi put on Tefilin at night. I asked if this was in order to guard them, and he said 'yes'. I could tell that it really wasn't in order to guard them. He holds that the Halachah permits this, but Ein Morin Ken (we do not tell this to one who asks).
Rishonim
Rif and Rosh (Hilchos Tefilin 9a and 16): One may wear Tefilin at night, but Ein Morin Ken.
Rambam (Hilchos Tefilin 4:11): If one put on Tefilin before Shki'ah (sundown) and it became dark, even if they are on the entire night, it is permitted, but Ein Morin Ken.
Rambam (12): If one did not remove Tefilin after Shki'ah because he had no place to guard them, and he wears them to guard them, it is permitted.
Sha'agas Arye (43): The Rambam did not rule like R. Elazar, who permits putting on Tefilin at night to guard them, for he holds that R. Elazar permits only without intent for the Mitzvah. The Isur to wear Tefilin at night is learned from "v'Shamarta Es ha'Chukah... mi'Yamim Yamimah." It is like the Mitzvah to wear during the day, i.e. for the sake of the Mitzvah. Anything not for the sake of the Mitzvah is permitted. This is called 'to guard them', for normally Tefilin are worn only for the Mitzvah or to guard them. If it were forbidden even not for the sake of the Mitzvah, and R. Elazar permits only in order to guard them, what is his source? The Torah does not hint to guarding them! Rather, the Torah permits anything not for the Mitzvah. If so, we can explain why the Rambam rules unlike R. Elazar. What is the source for R. Elazar and R. Yochanan to say that one who wears Tefilin at night transgresses a Lav or Aseh? They should say v'Shamarta discusses the Mitzvah to wear Tefilin during the day, and the Diyuk (inference) to exclude nights is only from a Chiyuv to wear Tefilin! The Torah excludes night from the Mitzvah of Tzitzis. We do not say that there is any Isur to wear Tzitzis at night! If we can explain v'Shamarta to discuss the Mitzvah itself, we should not say that it discusses the Diyuk. The Rosh says so in Mo'ed Katan in the name of Rabbeinu Meir mi'Rottenberg. This is logical. Also, R. Akiva says that Chukah refers to Pesach. In Eruvin, the Gemara suggested that he holds that there is a Lav of Korban Pesach, and answered that Hishamer" regarding an Aseh is an Aseh. I.e. Hishamer obligates people to offer Pesach in its time. He does not say that it forbids Pesach not in its time. Why do R. Elazar and R. Yochanan say that R. Yosi ha'Glili uses the verse to forbid wearing Tefilin at night? It is because we already have many verses obligating during the day. One who does not wear Tefilin transgresses eight Mitzvos Aseh (Menachos 43). Therefore, v'Shamarta forbids at night, which has no other source. R. Akiva says that Chukah refers to Pesach. Even if it forbids Pesach not in its time, e.g. before midday or on other days, it must be for an extra Isur. Pesach Lishmah at these times is Pasul, because it says many times that it must be in the afternoon of Erev Pesach. Therefore, it is better to say that the verse discusses Pesach itself. We cannot say so for R. Yosi ha'Glili. R. Yochanan must say that Hishamer teaches a Lav because he does not hold like R. Elazar, who permits in order to guard them.
Poskim
Shulchan Aruch (OC 30:2): One may not put on Tefilin at night, lest he forget them and sleep in them. If he did not remove Tefilin at Shki'ah because he had no place to guard them, and he wears them to guard them, it is permitted and Morin Ken.
Beis Yosef (OC 30 DH u'Mah she'Chosav Rabeinu Hainu): Sefer ha'Terumah and the Mordechai say that mid'Rabanan one may not put on Tefilin after Shki'ah, i.e. the end of Shki'ah, close to Tzeis ha'Kochavim. Rashi and the Rosh explain that R. Elazar says that in order to guard them, one may put them on even after Shki'ah. However, the Rambam says that the need to guard them permits only leaving them on, but not to put them on. This is like the Rif's text. All the Poskim hold like this. If so, we do not hold like R. Elazar. However, perhaps we rule like R. Elazar. Even though to guard them one may put them on l'Chatchilah, the Poskim omitted this, for they relied on what they wrote that if one needs to travel, he must put them on before the time. This is in order to guard them. The Rosh said that Rav Ashi put on Tefilin after Shki'ah. He told Ravina that this was to guard them, but really he holds that the Halachah permits this, but Ein Morin Ken. If so, one may put them on after Shki'ah, but Ein Morin Ken. This is unlike the Poskim. It seems that even the texts that say 'he was Meni'ach after Shki'ah' mean that he did not remove them. Surely one may not put them on if not to guard them. However, R. Yonah connotes that the Halachah permits putting them on at night, but Ein Morin Ken.
Beis Yosef (DH veha'Rambam): The Rambam permitted one who put on Tefilin before Shki'ah to leave them on the entire night. Why does he say afterwards that he may leave them on to guard them? Perhaps it is because in the latter case, Morin Ken. This is why he wrote only 'it is permitted', and did not say 'but Ein Morin Ken'. The case with Rav Ashi connotes that in order to guard them, it is permitted and Morin Ken. One could reject this and say that really, even to guard them Ein Morin Ken, but Rav Ashi said that he wore them to guard them because Ravina knew that it is permitted to guard them. This is why he asked 'do you intend to guard them?' This is not called Morin Ken. If the questioner did not know, perhaps Rav Ashi would not have said that it is permitted in order to guard them! The Rambam holds that since he admitted that it is permitted in order to guard them, this is Morin Ken. Since the Rif and Rambam agree that one may not put them on at night, we rule like them.
Magen Avraham (4): The Gemara connotes that one must say that he wears them in order to guard them.
Mishnah Berurah (9): One should not put them on l'Chatchilah at night to guard them. Some are lenient.