Where does the phrase “sword of Damocles” come from and What does it mean?

When Dionysius was ruler of Syracuse, back in the fourth century B.C., the courtier, Damocles, wishing to curry favor, began to praise the ruler one day.

He exclaimed over the power that Dionysius wielded, extolled his great wealth, and admired, above all, the luxurious life that he led and the comfort with which he was surrounded.

Dionysius, it is said, began to grow somewhat weary of this fulsome flattery, and asked the courtier if he would himself like to experience such a life.

Naturally, Damocles would like nothing better. So the ruler ordered that a bath should be prepared for Damocles, that he be arrayed in fine raiment, that a feast be set before him, and that dancers and singers should entertain him while he ate.

All this was done, and when Damocles had finished his sumptuous repast he lay back on the couch upon which he had been reclining, and was aghast to see over his head a heavy sword, hanging by a single hair. He jumped from the couch, asking the meaning of so ominous a threat.

“That,” said Dionysius, “is the threat of calamity that always imperils the life of anyone in high position, for others are always seeking his downfall.”

The story is told by various ancient writers, but the simile, expressing imminent danger, was not employed in English literature until a scant two hundred years ago.