What does the expression “handwriting on the wall” mean and Where does it come from?

The expression “handwriting on the wall” means: A forecast of some ominous event; a warning of probable danger.

The allusion is to the account told in the fifth chapter of Daniel in the Old Testament.

Belshazzar, to celebrate his access to the throne of Babylonia upon the death of his father, Nebuchadnezzar, declared a great feast, and, to signify the complete subjugation of the Jews, had the golden vessels that were taken out of the temple at Jerusalem brought out, “and the king, and his princes, his wives, and his concubines drank in them.”

At this sacrilege, “came forth fingers of a man’s hand, and wrote over against the candlestick upon the plaster of the wall.”

The words written were, “Mene, mene, tekel, upharsin.” The king demanded of Daniel, the Jewish prophet, an interpretation, and was told:

“This is the interpretation of the thing: Mene; God hath numbered thy kingdom, and finished it. Tekel; Thou art weighed in the balances, and art found wanting. Peres; Thy kingdom is divided, and given to the Medes and Persians.”

The chapter closes: “In that night was Belshazzar the king of the Chaldeans slain. And Darius the Median took the kingdom.”