Tractate Brachos of Talmud of Babylon 3b says this is a dispute between 2 tanaim (Rabbis in the period of the Mishna just under 2 millenia ago) whether there are 3 or 4 watches in the night:
תנו רבנן ארבע משמרות הוי הלילה דברי רבי רבי נתן אומר שלש
The Sages taught in a Tosefta: The night is comprised of four watches; this is the statement of Rabbi Yehuda HaNasi. Rabbi Natan says: The night is comprised of three watches.
מאי טעמיה דרבי נתן דכתיב ויבא גדעון ומאה איש אשר אתו בקצה המחנה ראש האשמרת התיכונה תנא אין תיכונה אלא שיש לפניה ולאחריה
The Gemara explains: What is Rabbi Natan’s reasoning? As it is written: “And Gideon, and the one hundred men who were with him, came to the edge of camp at the beginning of the middle watch” (Judges 7:19). It was taught in the Tosefta: Middle means nothing other than that there is one before it and one after it. From the fact that the verse refers to a middle watch, the fact that the night is comprised of three watches may be inferred.
מאי טעמיה דרבי אמר רבי זריקא אמר רבי אמי אמר רבי יהושע בן לוי כתוב אחד אומר חצות לילה אקום להודות לך על משפטי צדקך וכתוב אחד אומר קדמו עיני אשמורות הא כיצד ארבע משמרות הוי הלילה
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