The prophetic literature lays the groundwork for the entire discussion: Yirmiyahu 23:5 foretells that God will raise up for David a righteous branch who will reign as king and execute justice in the land, while Yechezkel 37:22 promises that Israel will be made into one nation under a single king — the scriptural foundation upon which all later belief is anchored.
The Gemara in Berakhot 34b teaches in the name of Rabbi Yochanan that all the prophets prophesied exclusively about the days of Mashiach, establishing that messianic expectation is woven through the entire prophetic corpus, not a peripheral theme.
The Rambam (Sanhedrin 10:1) codifies belief in Mashiach as the twelfth foundational principle of faith, requiring one to believe and trust that he will come, to await him without calculating a fixed time, and to affirm his supremacy over all kings — and he rules that whoever doubts or diminishes his stature thereby denies the Torah, which gives explicit testimony to him in the portions of Balak and Nitzavim.
Mishneh Torah, Melachim and Wars 11:1 goes further, ruling that whoever does not believe in Mashiach or does not await his coming is not merely rejecting the other prophets — he is rejecting the Torah and Moshe Rabeinu himself.
The Gemara in Shabbat 31a records that among the questions a person is asked at the heavenly judgment is whether he awaited salvation (צִפִּיתָ לִישׁוּעָה), indicating that this anticipation is treated as a personal obligation whose fulfillment is reckoned to one's account.
The Sefer HaIkkarim (Maamar 4, 42:1) agrees that belief in the coming of Mashiach is obligatory upon every adherent of Torah, reasoning that since the Torah commands one to heed the prophets — 'to him you shall listen' — and all the prophets prophesied about Mashiach's arrival, disbelieving in it constitutes a violation of a positive commandment; yet he draws a crucial distinction from the Sefer HaIkkarim (Maamar 4, 42:3), maintaining that this belief is not a foundational principle (ikkar) whose denial makes one a heretic in the fullest sense, but rather a genuine and binding obligation that falls short of that ultimate category.
Responsa Benei Banim, Volume III, Essays 3 clarifies the precise scope of the Rambam's position: the Rambam nowhere requires one to believe that Mashiach is about to arrive at any given moment, but only that one await him and believe in the general certainty of his coming, and the Rambam himself concluded his discussion by saying one should wait and believe 'in the general matter of these things' — not specifying whether his arrival is near or far.
Responsa Benei Banim, Volume IV 26 addresses the practical texture of this obligation, distinguishing between genuine anticipation, which is the requirement, and mere lip-service; it also engages with the question of whether identifying a specific deceased figure as Mashiach constitutes a halachic problem, and concludes, on our reading of the cited page, that while such a belief is foolish, its precise halachic status differs from the case of Rabbi Hillel in Sanhedrin who denied Mashiach would come to Israel at all.
Likkutei Sichos 28, Chukat concludes, on our reading of the cited page, that constant anticipation of Mashiach is a halachic requirement connected to the ongoing human need for spiritual purification, which will only be fully realized in the messianic era.