The matza and maror must be eaten by midnight (the midpoint of the night, regardless of the time on the clock), but if one was unable to eat them before midnight, he should eat them after midnight without a berakha. Le-khatĥila, even the afikoman should be eaten before midnight.
The basis for this law lies in a dispute between two Sages of the Mishna, R. Elazar b. Azarya and R. Akiva. According to R. Elazar b. Azarya, the Paschal sacrifice could be eaten only until midnight, and no later, because it was at midnight that the firstborns of Egypt were struck down, and the Egyptians began frantically trying to send the Israelites out of Egypt. According to R. Akiva, the matza may be eaten all night, until dawn, because it was at this time that the Israelites hurried to leave Egypt (Pesaĥim 120b).
From a spiritual perspective, we must explain that the offering and eating of the Paschal sacrifice revealed the unique quality of Israel, and this therefore constituted a preparation for the redemption. Accordingly, the meat of the korban Pesaĥ is eaten each year until the time of the redemption’s onset. The question is: which phase of redemption determines the time to stop eating the Paschal sacrifice? According to R. Elazar b. Azarya, the redemption started at midnight, when the firstborns of Egypt were struck down, for it was then that Egyptians’ power was broken and they could no longer enslave us. Therefore, the Paschal sacrifice is eaten until midnight. However, according to R. Akiva, the complete redemption did not arrive until morning, when we went forth to freedom. Therefore, the entire night is a preparation for redemption, and it follows that one may eat the meat of the korban Pesaĥ all night.
Let us now return to the halakha. The time for eating the Paschal sacrifice also determines the time for eating matza and maror, because matza and maror were eaten together with the Paschal sacrifice, as it is stated, “They shall eat it with matzot and merorim” (Bamidbar 9:11). It follows that the time for eating matza is the same as the time for eating the Paschal sacrifice. The afikoman, which is eaten in commemoration of the korban Pesaĥ, must also be eaten at a time that is appropriate for eating the Paschal sacrifice.
Leading Rishonim disagree about which opinion to follow in practice. According to Rambam and Itur, the halakha follows R. Akiva, because, as a rule, we follow R. Akiva whenever he takes issue with one of his contemporaries. Thus, the korban Pesaĥ may be eaten throughout the entire night, and by extension so can matza, maror, and the afikoman. On the other hand, Rabbeinu Ĥananel and Rosh maintain that because the Mishna, in several places, states without dissent that the time for eating the korban Pesaĥ is until midnight, we may conclude that R. Yehuda Ha-Nasi, who compiled the Mishna, rules that on this issue the halakha follows R. Elazar b. Azarya.
Since this issue is subject to dispute, a kezayit of matza must be eaten before midnight, because according to those who maintain that the Paschal sacrifice may be eaten until midnight, eating it after midnight fails to fulfill the Torah commandment. Since the destruction of the Temple, maror has been a rabbinic enactment, and although we generally follow the lenient opinion with regard to rabbinic laws, maror must nevertheless be eaten before midnight since we recite a berakha over it. If circumstances prevented one from eating the matza and maror before midnight, he should eat them after midnight, in order to fulfill the mitzva according to R. Akiva’s opinion. However, he should not recite the berakhot of “al akhilat matza” and “al akhilat maror,” so as to avoid reciting a berakha in vain (“le-vatala”) according to the opinion of R. Elazar b. Azarya (MB 477:6; Kaf Ha-ĥayim 10 ad loc.).
Regarding the afikoman, SA rules (477:1) that one must, le-khatĥila, eat it before midnight, in order to fulfill the mitzva according to all poskim. Similarly, Hallel should also be completed before midnight le-khatĥila, because it is connected to the telling of the Exodus story, which must be told at a time appropriate for eating matza.
There were Torah scholars who, le-khatĥila, ate the afikoman after midnight, reasoning that the afikoman is a rabbinic enactment and we may thus rely upon the lenient opinion that it may be eaten after midnight. However, with regard to the initial kezayit of matza, which is a Torah commandment, and the maror, over which we recite a berakha, one may not adopt the lenient position and eat them before midnight.
. A detailed explanation: On three occasions, the Mishna quotes the opinion of R. Elazar b. Azarya anonymously and without dissent – Berakhot 2a, Pesaĥim 120b, and Zevaĥim 56b – and R. Akiva’s opinion anonymously and without dissent only once, in Megilla 20b. Rosh (Pesaĥim 10:38) wonders how that single mishna in Megilla could outweigh the three mishnayot that follow the opinion of R. Elazar b. Azarya. Consequently, Rosh says that although R. Akiva maintains that on the Torah level, the mitzva of eating the korban Pesaĥ applies all night, he concurs that, on the rabbinic level, one must finish eating it before midnight. Therefore, Rosh states that one must eat the afikoman before midnight, and this is the ruling of SA 477:1. However, it is said that Ĥatam Sofer, Netziv, and other great scholars did not insist on finishing the afikoman before midnight. Since this is a dispute about a matter of rabbinic law, one may be lenient. Even SA might mean that one finishes the afikoman before midnight le-khatĥila, but it is not an absolute requirement. Responsa Avnei Nezer §381 recommends that one who is in the middle of his meal and sees that midnight is approaching should eat a kezayit of matza while reclining and make the following stipulation: If the halakha follows the opinion of R. Elazar b. Azarya, this kezayit should be the afikoman, but if the halakha follows R. Akiva, the kezayit that will be eaten after the meal (at its normal place in the meal) should be the afikoman. This stipulation is based on a novel interpretation: the requirement that the taste of the matza remains in one’s mouth only applies during the time of the mitzva, which according to R. Elazar b. Azarya ends at midnight. Thus, according to R. Elazar b. Azarya, one would be able to continue eating after midnight, when the time for the mitzva of afikoman ends.
However, one certainly must ensure that he eats a kezayit of matza before midnight, since eating a kezayit of matza is a Torah commandment, and hence one must be stringent. One must even be stringent vis-à-vis the mitzva of maror, since he cannot recite the berakha on it after midnight, as explained in MB 477:6 and BHL ad loc. Responsa Mishkenot Yaakov §139 and other Aĥaronim attempt to prove that the halakha follows Rambam. Nonetheless, the law still remains unclear, so one should not recite the berakhot on matza or maror after midnight and must likewise take care to fulfill the Torah obligation of matza before midnight. MB further states that if one begins late and does not have time to complete the recitation of the Hagada before midnight, he should eat the matza and maror, with berakhot, right after kiddush, and then recite the Hagada. Kaf Ha-ĥayim 477:10 echoes this idea, but rules that one may not recite the Birkat Ha-ge’ula (just before the second cup) after midnight, since we are lenient in a case of uncertainty regarding berakhot. See Ĥazon Ovadia vol. 2 p. 166, which agrees with MB and rules that one may recite Birkat Ha-ge’ula after midnight. Regarding the concluding berakha of Hallel, MB 477:7 and SHT 6 ad loc. cite Ĥok Yaakov that one may recite it after midnight. R. Harari’s Mikra’ei Kodesh, ch. 6 n. 70 demonstrates that be-di’avad one may recite Birkat Ha-ge’ula and the concluding berakha of Hallel after midnight.