(סב) חֲצֽוֹת־לַ֗יְלָה אָ֭קוּם לְהוֹד֣וֹת לָ֑ךְ עַ֝֗ל מִשְׁפְּטֵ֥י צִדְקֶֽךָ׃
(62) I arise at midnight to praise You
for Your just rules.
(קמח) קִדְּמ֣וּ עֵ֭ינַי אַשְׁמֻר֑וֹת לָ֝שִׂ֗יחַ בְּאִמְרָתֶֽךָ׃
(148) My eyes greet each watch of the night,
as I meditate on Your promise.
מַאי טַעְמֵיהּ דְּרַבִּי? אָמַר רַבִּי זְרִיקָא, אָמַר רַבִּי אַמֵּי, אָמַר רַבִּי יְהוֹשֻׁעַ בֶּן לֵוִי: כָּתוּב אֶחָד אוֹמֵר: ״חֲצוֹת לַיְלָה אָקוּם לְהוֹדוֹת לָךְ עַל מִשְׁפְּטֵי צִדְקֶךָ״, וְכָתוּב אֶחָד אוֹמֵר: ״קִדְּמוּ עֵינַי אַשְׁמוּרוֹת״ הָא כֵּיצַד, אַרְבַּע מִשְׁמָרוֹת הָוֵי הַלַּיְלָה. וְרַבִּי נָתָן, סָבַר לַהּ כְּרַבִּי יְהוֹשֻׁעַ. דִּתְנַן, רַבִּי יְהוֹשֻׁעַ אוֹמֵר: עַד שָׁלֹשׁ שָׁעוֹת, שֶׁכֵּן דֶּרֶךְ מְלָכִים לַעֲמֹוד בְּשָׁלֹשׁ שָׁעוֹת. שֵׁית דְּלֵילְיָא, וְתַרְתֵּי דִּימָמָא, הָווּ לְהוּ שְׁתֵּי מִשְׁמָרוֹת. רַב אָשֵׁי אָמַר: מִשְׁמָרָה וּפַלְגָא נָמֵי ״מִשְׁמָרוֹת״ קָרוּ לְהוּ.
What is Rabbi Yehuda HaNasi’s reasoning? Rabbi Zerika said that Rabbi Ami said that Rabbi Yehoshua ben Levi said: Rabbi Yehuda HaNasi’s opinion is based on a comparison of two verses. One verse says: “At midnight I rise to give thanks for Your righteous laws” (Psalms 119:62), and the other verse says: “My eyes forestall the watches, that I will speak of Your word” (Psalms 119:148). Taken together, these verses indicate that their author, King David, rose at midnight, two watches before dawn, in order to study Torah. How is it possible to reconcile these two verses? Only if there are four watches in the night does one who rises two watches before dawn rise at midnight. And how does Rabbi Natan reconcile these two verses? He holds in accordance with the opinion of Rabbi Yehoshua, for we learned in a mishna that Rabbi Yehoshua says: One is permitted to recite the morning Shema during the time when people rise, until the third hour of the day, as it is the custom of kings to rise during the third hour. Since it is customary for kings to rise during the third hour of the day, if David rose at midnight, he would be awake for six hours of the night and two hours of the day, which amounts to two watches. Therefore King David could say that he “forestalls the watches,” as he rose two watches before the rest of the kings in the world. Rav Ashi said that the verses can be reconciled in accordance with Rabbi Natan’s opinion in another way: One and one-half watches are still called watches in plural. Therefore King David could rise at midnight yet maintain that he “forestalls the watches.”
(ד) הִנֵּ֣ה לֹֽא־יָ֭נוּם וְלֹ֣א יִישָׁ֑ן שׁ֝וֹמֵ֗ר יִשְׂרָאֵֽל׃
(4) See, the guardian of Israel
neither slumbers nor sleeps!

מַעֲשֶׂה בְרַבִּי אֱלִיעֶזֶר וְרַבִּי יְהוֹשֻׁעַ וְרַבִּי אֶלְעָזָר בֶּן־עֲזַרְיָה וְרַבִּי עֲקִיבָא וְרַבִּי טַרְפוֹן שֶׁהָיוּ מְסֻבִּין בִּבְנֵי־בְרַק וְהָיוּ מְסַפְּרִים בִּיצִיאַת מִצְרַיִם כָּל־אוֹתוֹ הַלַּיְלָה, עַד שֶׁבָּאוּ תַלְמִידֵיהֶם וְאָמְרוּ לָהֶם רַבּוֹתֵינוּ הִגִּיעַ זְמַן קְרִיאַת שְׁמַע שֶׁל שַׁחֲרִית.

מַעֲשֶׁה ONCE,
Rabbi Eliezer and Rabbi Yehoshua and Rabbi Elazar ben Azaria
and Rabbi Akiva and Rabbi Tarfon
reclined [for the seder] in Benei Brak.
And they told of the Exodus from Egypt all that night;
until their students came in and said,
“Teachers –
the time for saying the Shema of the morning has come.”

אָמַר רַבִּי אֶלְעָזָר בֶּן־עֲזַרְיָה הֲרֵי אֲנִי כְּבֶן שִׁבְעִים שָׁנָה וְלֹא זָכִיתִי שֶׁתֵּאָמֵר יְצִיאַת מִצְרַיִם בַּלֵּילוֹת עַד שֶׁדְּרָשָׁהּ בֶּן זוֹמָא, שֶׁנֶּאֱמַר, לְמַעַן תִּזְכֹּר אֶת יוֹם צֵאתְךָ מֵאֶרֶץ מִצְרַיִם כֹּל יְמֵי חַיֶּיךָ. יְמֵי חַיֶּיךָ הַיָּמִים. כֹּל יְמֵי חַיֶּיךָ הַלֵּילוֹת. וַחֲכָמִים אוֹמְרִים יְמֵי חַיֶּיךָ הָעוֹלָם הַזֶּה. כֹּל יְמֵי חַיֶּיךָ לְהָבִיא לִימוֹת הַמָּשִׁיחַ:

Rabbi Elazar ben Azaria said:
I am almost seventy years old,
and never have I merited to find the command
to speak of the Exodus from Egypt at night –
until Ben Zoma interpreted:
It is written,
“SO THAT YOU REMEMBER
THE DAY OF YOUR EXODUS FROM EGYPT
ALL THE DAYS OF YOUR LIFE.”
“The days of your life” would mean in the days;
“all the days of your life” includes the nights.
But the sages say,
“The days of your life” would mean only in this world;
“all the days of your life” brings in the time of the Messiah.

​​​​​​​The earliest recorded case of a Tikkun Leil Shavuot being practiced was in Greece, in the year 1533 (or thereabouts), and it was a remarkable one. Present were R. Yosef Karo, later the author of the Shulchan Aruch, R. Shlomo HaLevi Alkabetz, later the composer of Lecha Dodi, and other unnamed members of their circle. A few years later, R. Alkabetz wrote of the experience. (Below is an excerpt from his letter. There's more to this story than we can tell here...)
דעו לכם כי הסכמנו החסיד נר"ו ואני עבדו ועבידכם מהחברים לעמוד על נפשינו ליל שבועות ולנדד שינה מעינינו, ותהלות ליי כן עלה בידינו כי לא הפסקנו רגע רק אשר תשמעו ותחי נפשכם...
ובעת שהתחלנו ללמוד המשנה ולמדנו שתי מסכתות, זיכנו בוראנו ונשמע את קול המדבר בפי החסיד נר"ו קול גדול בחיתוך אותיות, וכל השכנים היו שומעים ולא מבינים, והיה הנעימות רב והקול הולך וחזק, ונפלנו על פנינו ולא היה רוח באיש לישא עיניו ופניו לראות מרוב המורא והדיבור ההוא מדבר עמנו והתחיל ואמר, שמעו ידידי המהדרים מן המהדרים, ידידי אהובי שלום לכם אשריכם ואשרי ילדתכם, אשריכם בעולם הזה אשריכם בעולם הבא אשר שמתם על נפשיכם לעטרני בלילה הזה אשר זה כמה שנים נפלה עטרת ראשי ואין מנחם לי, ואני מושלכת בעפר חובקת אשפתות, ועתה החזרתם עטרה ליושנה...
Know - that the pious one (R. Yosef Karo) and I agreed to make a great effort on the night of Shavuot, and to keep sleep from our eyes. Praise to God, so it was. We didn't stop one moment - listen, and your soul will be revived...
The moment that we began to learn the Mishnah, and we learned two mesechtot, our creator graced us and we heard a voice speaking from the mouth of the pious one. A great voice, with clear enunciation, and all around us heard but did not understand. It was very pleasant, and the voice gained strength. We fell on our faces, and none could raise their eyes from fear. The voice speaking to us began and said - "Hear my beloved ones, most beautiful, cherished, beloved, peace to you, fortunate are you and those that bore you, fortunate in this world and in the world to come, in that you took upon yourselves to crown me this night. It is many years that my crown has fallen from my head, and I have no one to comfort me, and I am cast to the dirt clutching waste. But you have returned the crown to its former glory...

בליל רִאשון אומרים:

וּבְכֵן וַיְהִי בַּחֲצִי הַלַּיְלָה.

אָז רוֹב נִסִּים הִפְלֵאתָ בַּלַּיְלָה, בְּרֹאשׁ אַשְׁמוֹרֶת זֶה הַלַּיְלָה.

גֵר צֶדֶק נִצַּחְתּוֹ כְּנֶחֶלַק לוֹ לַיְלָה, וַיְהִי בַּחֲצִי הַלַּיְלָה.

דַּנְתָּ מֶלֶךְ גְּרָר בַּחֲלוֹם הַלַּיְלָה, הִפְחַדְתָּ אֲרַמִּי בְּאֶמֶשׁ לַיְלָה.

וַיָּשַׂר יִשְׂרָאֵל לְמַלְאָךְ וַיּוּכַל לוֹ לַיְלָה, וַיְהִי בַּחֲצִי הַלַּיְלָה.

זֶרַע בְּכוֹרֵי פַתְרוֹס מָחַצְתָּ בַּחֲצִי הַלַּיְלָה, חֵילָם לֹא מָצְאוּ בְּקוּמָם בַּלַּיְלָה, טִיסַת נְגִיד חֲרֹשֶׁת סִלִּיתָ בְּכוֹכְבֵי לַיְלָה, וַיְהִי בַּחֲצִי הַלַּיְלָה.

יָעַץ מְחָרֵף לְנוֹפֵף אִוּוּי, הוֹבַשְׁתָּ פְגָרָיו בַּלַּיְלָה, כָּרַע בֵּל וּמַצָּבוֹ בְּאִישׁוֹן לַיְלָה, לְאִישׁ חֲמוּדוֹת נִגְלָה רָז חֲזוֹת לַיְלָה, וַיְהִי בַּחֲצִי הַלַּיְלָה.

מִשְׁתַּכֵּר בִּכְלֵי קֹדֶשׁ נֶהֱרַג בּוֹ בַלַּיְלָה, נוֹשַׁע מִבּוֹר אֲרָיוֹת פּוֹתֵר בִּעֲתוּתֵי לַיְלָה, שִׂנְאָה נָטַר אֲגָגִי וְכָתַב סְפָרִים בַּלַּיְלָה, וַיְהִי בַּחֲצִי הַלַּיְלָה.

עוֹרַרְתָּ נִצְחֲךָ עָלָיו בְּנֶדֶד שְׁנַת לַיְלָה. פּוּרָה תִדְרוֹךְ לְשׁוֹמֵר מַה מִּלַיְלָה, צָרַח כַּשּׁוֹמֵר וְשָׂח אָתָא בֹקֶר וְגַם לַיְלָה, וַיְהִי בַּחֲצִי הַלַּיְלָה.

קָרֵב יוֹם אֲשֶׁר הוּא לֹא יוֹם וְלֹא לַיְלָה, רָם הוֹדַע כִּי לְךָ הַיּוֹם אַף לְךָ הַלַּיְלָה, שׁוֹמְרִים הַפְקֵד לְעִירְךָ כָּל הַיּוֹם וְכָל הַלַּיְלָה, תָּאִיר כְּאוֹר יוֹם חֶשְׁכַּת לַיְלָה, וַיְהִי בַּחֲצִי הַלַּיְלָה.

Outside Israel, this poem is recited on the first night of the festival only.

וּבְכֵן וַיְהִי בַּחֲצִי הַלַּיְלָה AND so – IT HAPPENED AT MIDNIGHT.

Many were the miracles You performed long ago, at night.

At the beginning of the watch, on this night,
You won [Abraham]’s battle, when [his men were] split, and the night
IT HAPPENED AT MIDNIGHT.

You judged the king of Gerar in his dream at night.
You put dread into [Laban] the Aramean’s heart that night.

And Israel struggled with an angel and overcame him at night
IT HAPPENED AT MIDNIGHT.

You crushed the firstborns of Patros [Egypt] in the middle of the night.
They could not find their strength, when they rose up
[against Israel] at night.
You flung [Sisera] the commander of Haroshet
off course with the stars of night
IT HAPPENED AT MIDNIGHT.

[Sennacherib] the blasphemer thought to raise his hand
against the beloved [city]; but You dried up the bodies
of his fallen in the night.
You overthrew Bel, idol and pedestal together, in the dead of night.
To [Daniel] the beloved man were revealed
the secrets of that vision of the night
IT HAPPENED AT MIDNIGHT.

[Belshazzar], who drank himself merry
from the holy vessels, was killed on that same night.
[Daniel] was brought out unharmed from the
lions’ den; he who had explained those terrors of the night.
[Haman] the Agagite bore his hatred and wrote his orders at night
IT HAPPENED AT MIDNIGHT.

You awakened Your might against him, disturbing
[King Ahashverosh’s] sleep at night.
You shall tread the winepress of [Se’ir],
who asks anxiously, “What of the night?”
You will cry out like the watchman, calling,
“Morning is come, and also night”
IT HAPPENED AT MIDNIGHT.

Draw near the day that will be neither day nor night.
Highest One, make known that day is Yours and also night.
Appoint watchmen [to guard] Your city all day long and all night,
Light up like daylight the darkness of night
IT HAPPENED AT MIDNIGHT.