A phrase recalling an Old Testament story about Daniel. While a king was holding the Jews captive in the foreign land of Babylon, in the sixth century b.c., a mysterious hand appeared, writing on the wall of the king's palace. The king called upon Daniel, who interpreted it to mean that God intended the king and his kingdom to fall. The king was slain that night.
Note: Figuratively, the expression means that some misfortune is impending: “His firing came as no surprise; he'd seen the handwriting on the wall months before.”