The end of the world (due to start this year on 21 May, according to Californian preacher Harold Camping) has had a long and curious history. Although several religions or myth systems have stories about the end of everything, the hope of the last judgment is essential to Christianity. But the idea that you could predict it on a calendar came only with the beginnings of modern science in the 17th century. The plan of working backwards to the beginning of the world is well known: by adding the genealogies of the Old Testament onto our modern, written dating systems you can count back to a date for the fall of around 4004. Predicting it forward, however, became an urgent and polemical matter during the Reformation, and the first people to suggest the way were Jesuits.

This is because the apocalyptic fantasies of the Book of Daniel suggested that the church would be threatened by harlots and horned beasts before the day of judgment, and the Protestant interpretation was that this had already happened. That's why Ian Paisley clings to the rhetoric of Rome as the scarlet woman of Babylon. The papacy is the prophesied antichrist.

Naturally, this wasn't an interpretation that the Roman Catholics could accept. They preferred to read the prophecies of the tribulation as referring to something that had not happened yet. If the antichrist is due in the future, then the Roman Catholic church could not be it.

The modern interpretation of the prophecies in Daniel and Revelation is that they are coded references to contemporary politics and all the tyrants, harlots and horned beasts in them are long since forgotten dust. But prophecy is much more fun. By close study of the Book of Daniel, the Spanish Jesuit Francisco Ribera further invented the doctrine of the Rapture. This breaks the last judgment into two parts – first the real Christians are swept up into heaven, then the bad stuff happens to the rest of us.

Since this was a Jesuit doctrine, it was completely unacceptable to Protestants until the 19th century, when it was republished by another Jesuit, writing pseudonymously as a rabbi. From Jewish sources, it made perfect sense to Edward Irving, a fashionable Scottish preacher in London in the 1820s. By the 1830s his congregation was speaking tongues and prophesying and claiming miraculous healings, like an early version of Holy Trinity Brompton.

From there the doctrine crossed the Atlantic. William Miller, a Baptist minister in upstate New York, decided that when the Book of Daniel said "Unto two thousand and three hundred days; then shall the sanctuary be cleansed", it obviously meant 2,300 years; and by "the sanctuary being cleansed" it obviously meant the return of Jesus: all he had to do was to establish the date from which Daniel was counting, and all would be ready.

What followed was a series of letdowns through the years 1843 and 1844, culminating 22 October 1844, when Jesus once more failed to reappear. This date is known as the Great Disappointment.

Some of the disappointed believers concluded they had been wrong in their theory, but most simply decided that they had been wrong in their calculations. The most ingenious reinterpretation gave rise to the Seventh-day Adventists, who believed that Jesus had, in fact, already come back, exactly as prophesied and predicted but that we were too sinful to see it. This theory gave rise, in due course, to cornflakes, since an Adventist businessman decided he could diminish the amount of lust in the world by promoting vegetarian breakfasts. His name was Kellogg.

Outside the breakfast table, Adventism gave rise to other sects, most notably the Jehovah's Witnesses, who originally had the end of the world pegged for 1914. They must have felt for much of that year as if they were onto a sure thing.

In the 1950s a small sect in Chicago became convinced that the end of the world was imminent. They believed in flying saucers rather than Christian myth, but the underlying pattern was the same: when the end failed to happen, most members grew even more convinced they were right all along and redoubled their attempts to proseltyse them. Psychologist Leon Festinger, gave the phenomenon a name: "cognitive dissonance".

Of course this phenomenon is not confined to religious believers. But what distinguished Rapture fantasies from daydreaming that you have won the lottery is that they tend to be collective. In a Rapture, it is not just you, but all the good people who are swept up into another world, and all the bastards are left behind to suffer. This is far too attractive an idea to be disconfirmed, and I prophesy with complete certainty that by 21 May next year the Rev Harold Camping will have an explanation for why he was right all along. And why not? Carry on, Camping.