The full story should contain something like this: The King said: "If your statement is true, you will be hanged; if it is false, you will be beheaded instead."
Will he be hanged? If so, the statement turns out to be true, but then he will not be hanged according to the King's promise. Will he be beheaded? If so, that would make his prediction correct, so that he should be hanged, not beheaded.