The Talmud in tractate Gittin preserves a wild stretch of stories in which Benaiah ben Yehoyada, one of King David's mighty men, captures Ashmedai, king of the demons, and leads him toward Jerusalem. Along the road Ashmedai does five strange things — and each of them turns out to be a small prophecy.
He sees a blind man wandering off the path and promptly guides him back. "Why?" asked Benaiah. "Because," said Ashmedai, "it was proclaimed in heaven that this man is perfectly righteous, and whoever does him a good turn earns a place in the world to come."
Later they passed a drunk man staggering into the bushes, and Ashmedai put him back on the road as well. "Why that one?" "Because it was proclaimed that he is thoroughly wicked. I have done him a good service, that he might not lose everything, but receive at least some good in the world that now is."
Then they met a wedding party, and Ashmedai wept. "The bridegroom is fated to die within thirty days, and the bride must wait thirteen years for her husband's brother, who is now an infant" (as required in Deuteronomy 25:5-10).
A man was ordering shoes that would last him seven years; Ashmedai laughed, because the man was not sure of living seven days. A conjuror was working his tricks for a crowd; Ashmedai jeered, because the man was sitting on a royal treasure buried beneath him and did not know it.
The demon sees what the righteous cannot: every scene is a verdict already written in heaven.