But our teachers the Tosafists, and the Rif, and the Rosh, and the Semag ruled like Rabbi Akiva, because Rav Ashi holds accordingly. And night, according to the Torah, is a time for tefillin, and only by rabbinic decree did they forbid donning them ab initio at night, lest one sleep in them. And so they ruled in the Tur and Shulchan Aruch. This is the wording of our teacher, the Beit Yosef, in section 2: It is forbidden to don tefillin at night, lest one forget them and sleep in them. And if he donned them before the sun set and it grew dark upon him, even if they are upon him all night – it is permitted. But we do not instruct thus (and in public he must remove them). And if he did not remove his tefillin after the sun set because he had no place to guard them, and they were found upon him in order to guard them – it is permitted and we instruct thus. Thus far his words. And he must say that he is doing so in order to guard them (Magen Avraham). And the Rambam also wrote these laws. Now, if it is in order to guard them, it is explicit in the Gemara that it is permitted, even if night is not a time for tefillin as I have written. But the first law, that if it grew dark upon him – it is permitted but we do not instruct thus, why did he write it? For in the Gemara this was only according to the one who holds that night is a time for tefillin. And it appears clearly that the Rambam explains the Gemara with a different explanation, in a manner that this is even according to the one who says night is not a time for tefillin. (And this is the explanation: We sat before Rav Ashi and it grew dark and he donned tefillin, meaning: he did not remove them… – it is the halacha but we do not instruct thus. Meaning: it is the halacha that from the Torah it is forbidden to don them at night, but to remove them there is no Torah obligation, yet we do not instruct thus if it is not to guard them. And according to this, the reasoning of the Rambam is revealed, for he ruled like Rabbi Yosei HaGelili because he explains that Rav Ashi also holds like Rabbi Yosei HaGelili. And according to this, it can be said that the Rif also holds accordingly, for he wrote: And the halacha is like Rav Ashi. And according to the Rambam's explanation, it does not contradict the words of Rabbi Yochanan. And according to this, that which the Rif also brought the words of Rabbi Yochanan works out well. And the great Acharonim labored much over their words, and in my humble opinion it is clear that their reasoning is such. Examine carefully and you will find it simple.)
אבל רבותינו בעלי התוספות, והרי"ף, והרא"ש, והסמ"ג פסקו כרבי עקיבא, משום דרב אשי סובר כן. ולילה מן התורה זמן תפילין, ורק מדרבנן אסרו להניחם לכתחילה בלילה, שמא יישן בהם. וכן פסקו בטור ושולחן ערוך. וזה לשונו רבינו הבית יוסף בסעיף ב: אסור להניח תפילין בלילה, שמא ישכחם ויישן בהם. ואם הניחם קודם שתשקע החמה וחשכה עליו, אפילו הם עליו כל הלילה – מותר. ואין מורין כן (וברבים צריך לחלצן). ואם לא חלץ תפיליו מששקעה חמה מפני שלא היה לו מקום לשמרן, ונמצאו עליו כדי לשומרן – מותר ומורין כן. עד כאן לשונו. וצריך שיאמר שעושה כדי לשמרן (מגן אברהם). וגם הרמב"ם כתב דינים אלו. והנה אם כדי לשמרם מפורש בגמרא דמותר, אפילו אי לילה לאו זמן תפילין כמו שכתבתי. אבל הדין הראשון דאם חשכה עליו – מותר ואין מורין כן, למה כתב? הא בגמרא הוה זה רק למאן דסבירא ליה לילה זמן תפילין. ונראה להדיא שהרמב"ם מפרש פירוש אחר בגמרא, באופן דזהו אפילו למאן דאמר לילה לאו זמן תפילין. (והכי פירושו: יתיבנא קמי דרב אשי וחשך והניח תפילין, כלומר: שלא חלצן… – הלכה ואין מורין כן. כלומר: הלכה שמן התורה אסור להניחן בלילה, אבל לחלצן אין חיוב מן התורה, אך אין מורין כן אם אינו לשמרם. ולפי זה נתגלה טעמו של הרמב"ם שפסק כרבי יוסי הגלילי, משום דמפרש דגם רב אשי סבירא ליה כרבי יוסי הגלילי. ולפי זה יש לומר דגם הרי"ף סובר כן, דהוא כתב: והלכה כרב אשי. ולפירוש הרמב"ם אינו סותר לדרבי יוחנן. ולפי זה אתי שפיר מה שהביא הרי"ף גם דברי רבי יוחנן. וגדולי אחרונים טרחו הרבה בדבריהם, ולעניות דעתי ברור בטעמם שכן הוא. ודייק ותמצא קל.)