Devarim9:18

וָאֶתְנַפַּל לִפְנֵי יְהוָה כָּרִאשֹׁנָה אַרְבָּעִים יוֹם וְאַרְבָּעִים לַיְלָה לֶחֶם לֹא אָכַלְתִּי וּמַיִם לֹא שָׁתִיתִי עַל כָּל־חַטַּאתְכֶם אֲשֶׁר חֲטָאתֶם לַעֲשׂוֹת הָרַע בְּעֵינֵי יְהוָה לְהַכְעִיסוֹ׃

And I fell down before the Eternal, as at the first, forty days and forty nights: I ate no bread and drank no water, because of all your sin which you had sinned, in doing what was evil in the eyes of the Eternal, to provoke Him.

Devarim 9:18

וָאֶתְנַפַּל לִפְנֵי יְהוָה

Devarim / Deuteronomy 9:18

וָאֶתְנַפַּל לִפְנֵי יְהוָה כָּרִאשֹׁנָה אַרְבָּעִים יוֹם וְאַרְבָּעִים לַיְלָה לֶחֶם לֹא אָכַלְתִּי וּמַיִם לֹא שָׁתִיתִי עַל כָּל־חַטַּאתְכֶם אֲשֶׁר חֲטָאתֶם לַעֲשׂוֹת הָרַע בְּעֵינֵי יְהוָה לְהַכְעִיסוֹ׃

And I fell down before the Eternal, as at the first, forty days and forty nights: I ate no bread and drank no water, because of all your sin which you had sinned, in doing what was evil in the eyes of the Eternal, to provoke Him.

Pshat פְּשָׁט

Three times forty days

Rashi: Moshe was on the mountain three times for forty days. The middle forty days passed in anger and ended on the twenty-ninth of Av. The last ones, in goodwill, ended on Yom Kippur, and on that day the Eternal said with joy: "I have forgiven according to your word." That is why this day was set for forgiveness. Malbim: already the first time the Eternal relented of destroying the people, but the anger still remained, and He thought to punish them another way. Only after the second forty days of prayer did He listen to Moshe and become reconciled with them.

How Rashi and Malbim explain it

Remez רֶמֶז

The time of a prayer

Midrash Lekach Tov: Moshe (Moses) went without food and drink for a hundred and twenty days in a row, three times forty. The last forty ended on Yom Kippur, and that is why in some places the shofar is blown from the first day of the month of Elul. Midrash Aggadah: every prayer has its own time. One waits a hundred years for an answer, another two years, a third forty days, like the prayer of Moshe. And sometimes the answer comes before a person has finished speaking.

How Midrash Lekach Tov and Midrash Aggadah explain it

Drash דְּרָשׁ

A teacher of prayer

Midrash Tanchuma (Buber): one rises to pray only in seriousness, and the forefathers prayed in awe. Moshe fell down before the Eternal to defend Israel, but the Eternal accepted his prayer only when he recalled the merit of the fathers. Then the Holy One, blessed is He, wrapped Himself in a tallit like a prayer leader and showed Moshe how to pray: "The Eternal, the Eternal, God compassionate and gracious." The righteous seek merit even for the wicked, as Avraham pleaded for Sodom. Rabbeinu Bahya brings Midrash Tehillim: Moshe left no corner of the heavens where he did not pray.

How Midrash Tanchuma (Buber) and Rabbeinu Bahya explain it

Sod סוֹד

Two prayers

Rabbeinu Bahya: there were two prayers. For forty days Moshe prayed to the special Name, for the sin of the calf provoked that Name. Then he prayed to the attribute of justice: "Lord Eternal, do not destroy." The Name אֲדֹנָי, which stands here before the Name of the Eternal, shows that in his plea Moshe needed the attribute of justice.

How Rabbeinu Bahya explain it