Since 1839, the world inventory of photographs has been accumulating at an accelerating pace, multiplying into a near infinitude of images, into a resemblance of a Borgesian library. This haunting technology has been with us long enough now that we are able to look at a crowd scene, a busy street, say, in the late 19th century and know for certain that every single figure is dead. Not only the young couple pausing by a park railing, but the child with a hoop and stick, the starchy nurse, the solemn baby upright in its carriage - their lives have run their course, and they are all gone. And yet, frozen in sepia, they appear curiously, busily, oblivious of the fact that they must die - as Susan Sontag put it, "photographs state the innocence, the vulnerability of lives heading towards their own destruction ..."

"Photography," she said, "is the inventory of mortality. A touch of the finger now suffices to invest a moment with posthumous irony. Photographs show people being so irrefutably there and at a specific age in their lives; [they] group together people and things which a moment later have already disbanded, changed, continued along the course of their independent destinies."

We are well used to reflections on individual mortality - it is the shaping force in the narrative of our existence. It emerges in childhood as a baffling fact, re-emerges possibly in adolescence as a tragic reality which all around us appear to be denying, then perhaps fades in busy middle life, to return, say, in a sudden premonitory bout of insomnia. One of the supreme secular meditations on death is Larkin's "Aubade":

... The sure extinction that we travel to

And shall be lost in always. Not to be here,

Not to be anywhere,

And soon; nothing more terrible, nothing more true.

We confront our mortality in private conversations, in the familiar consolations of religion - "That vast moth-eaten musical brocade," thought Larkin, "Created to pretend we never die." And we experience it as a creative tension, an enabling paradox in our literature and art: what is depicted, loved, or celebrated cannot last, and the work must try to outlive its creator. Larkin, after all, is now dead. Unless we are a determined, well-organised suicide, we cannot know the date of our demise, but we know the date must fall within a certain window of biological possibility which, as we age, must progressively narrow to its closing point.

Estimating the nature and timing of our collective demise, the end of civilisation, of the entire human project, is even less certain - it might happen in the next hundred years, or not happen in two thousand, or happen with imperceptible slowness, a whimper, not a bang. But in the face of that unknowability, there has often flourished powerful certainty about the approaching end. Throughout recorded history people have mesmerised themselves with stories which predict the date and manner of our wholescale destruction, often rendered meaningful by ideas of divine punishment and ultimate redemption; the end of life on earth, the end or last days, end time, the apocalypse.

Many of these stories are highly specific accounts of the future and are devoutly believed. Contemporary apocalyptic movements, Christian or Islamic, some violent, some not, all appear to share fantasies of a violent end, and they affect our politics profoundly. The apocalyptic mind can be demonising - that is to say, there are other groups, other faiths, that it despises for worshipping false gods, and these believers of course will not be saved from the fires of hell. And the apocalyptic mind tends to be totalitarian - which is to say that these are intact, all-encompassing ideas founded in longing and supernatural belief, immune to evidence or its lack, and well-protected against the implications of fresh data. Consequently, moments of unintentional pathos, even comedy, arise - and perhaps something in our nature is revealed - as the future is constantly having to be rewritten, new anti-Christs, new Beasts, new Babylons, new Whores located, and the old appointments with doom and redemption quickly replaced by the next.

Not even a superficial student of the Christian apocalypse could afford to ignore the work of Norman Cohn. His magisterial The Pursuit of the Millennium was published 50 years ago and has been in print ever since. This is a study of a variety of end-time movements that swept through northern Europe between the 11th and 16th centuries. These sects, generally inspired by the symbolism in the Book of Revelation, typically led by a charismatic prophet who emerged from among the artisan class or from the dispossessed, were seized by the notion of an impending end, to be followed by the establishing of the Kingdom of God on earth. In preparation for this, it was believed necessary to slaughter Jews, priests and property owners. Fanatical rabbles, tens of thousands strong, oppressed and often starving and homeless, roamed from town to town, full of wild hope and murderous intent. The authorities, church and lay, would put down these bands with overwhelming violence. A few years or a generation later, with a new leader, and a faintly different emphasis, a new group would rise up. It is worth remembering that the impoverished mob that trailed behind the knights of the first crusades started their journey by killing Jews in the thousands in the Upper Rhine area. These days, when Muslims of radical tendency pronounce their formulaic imprecations against "Jews and Cru-saders", they would do well to remember that both Jewry and Islam were victims of the crusades.

Now, the slaughter has abated, but what strikes the reader of Cohn's book are the common threads that run between medieval and contemporary apocalyptic thought. First, and in general, the resilience of the end-time forecasts - time and again, for 500 years, the date is proclaimed, nothing happens, and no one feels discouraged from setting another date. Second, the Book of Revelation spawned a literary tradition that kept alive in medieval Europe the fantasy, derived from the Judaic tradition, of divine election. Christians, too, could now be the Chosen People, the saved or the Elect, and no amount of official repression could smother the appeal of this notion to the unprivileged as well as the unbalanced. Third, there looms the figure of a mere man, apparently virtuous, risen to eminence, but in reality seductive and Satanic - he is the anti-Christ, and in the five centuries that Cohn surveys, the role is fulfilled by the Pope, just as it frequently is now.

Finally, there is the boundless adaptability, the undying appeal and fascination of the Book of Revelation itself, the central text of apocalyptic belief. When Christopher Columbus arrived in the Americas, making landfall in the Bahaman islands, he believed he had found, and was fated to find, the Terrestrial Paradise promised in the Book of Revelation. He believed himself to be implicated in God's planning for the millennial kingdom on earth. The scholar Daniel Wojcik (in his brilliant account of apocalyptic thought in America, "The end of the world as we know it") quotes from Columbus's record of his first journey: "God made me the messenger of the new heaven and the new earth of which he spoke in the Apocalypse of St John ... and he showed me the spot where to find it."

Five centuries later, the United States, responsible for more than four-fifths of the world's scientific research and still a land of plenty, can show the world an abundance of opinion polls concerning its religious convictions. The litany will be familiar. Ninety per cent of Americans say they have never doubted the existence of God and are certain they will be called to answer for their sins. Fifty-three per cent are creationists who believe that the cosmos is 6,000 years old, 44 per cent are sure that Jesus will return to judge the living and the dead within the next 50 years. Only 12 per cent believe that life on earth has evolved through natural selection without the intervention of supernatural agency.

In general, belief in end-time biblical prophecy, in a world purified by catastrophe and then redeemed and made entirely Christian and free of conflict by the return of Jesus in our lifetime, is stronger in the United States than anywhere on the planet and extends from marginal, ill-educated, economically deprived groups, to college-educated people in the millions, through to governing elites, to the very summits of power. The social scientist JW Nelson notes that apocalyptic ideas "are as American as the hot dog". Wojcik reminds us of the ripple of anxiety that ran round the world in April 1984 when President Reagan expressed that he was greatly interested in the biblical prophecy of imminent Armageddon.

To the secular mind, the polling figures have a pleasantly shocking, titillating quality - one might think of them as a form of atheist's pornography. But perhaps we should enter a caveat before proceeding. It might be worth retaining a degree of scepticism about these polling figures. For a start, they vary enormously - one poll's 90 per cent is another's 53 per cent. From the respondent's point of view, what is to be gained by categorically denying the existence of God to a complete stranger with a clipboard? And those who tell pollsters they believe that the Bible is the literal word of God from which derive all proper moral precepts, are more likely to be thinking in general terms of love, compassion and forgiveness rather than of the slave-owning, ethnic cleansing, infanticide, and genocide urged at various times by the jealous God of the Old Testament.

Furthermore, the mind is capable of artful compartmentalisations; in one moment, a man might confidently believe in predictions of Armageddon in his lifetime, and in the next, he might pick up the phone to inquire about a savings fund for his grandchildren's college education or approve of long-term measures to slow global warming. Or he might even vote Democrat, as do many Hispanic biblical literalists. In Pennsylvania, Kansas and Ohio, the courts have issued ringing rejections of Intelligent Design, and voters have ejected creationists from school boards. In the Dover case in 2005, Judge John Jones III, a Bush appointee, handed down a judgment that was not only a scathing dismissal of the prospect of supernatural ideas imported into science classes, but was an elegant, stirring summary of the project of science in general, and of natural selection in particular, and a sturdy endorsement of the rationalist, Enlightenment values that underlie the Constitution.

Still the Book of Revelation, the final book of the Bible, and perhaps its most bizarre, certainly one of its most lurid, remains important in the United States, just as it once was in medieval Europe. The book is also known as the Apocalypse - and we should be clear about the meaning of this word, which is derived from the Greek word for revelation. Apocalypse, which has become synonymous with "catastrophe", actually refers to the literary form in which an individual describes what has been revealed to him by a supernatural being. There was a long Jewish tradition of prophecy, and there were hundreds, if not thousands of seers like John of Patmos between the second century BC and the first century AD. Many other Christian apocalypses were deprived of canonical authority in the second century AD. Revelation most likely survived because its author was confused with John, the Beloved Disciple. It is interesting to speculate how different medieval European history, and indeed the history of religion in Europe and the United States, would have been if the Book of Revelation had also failed, as it nearly did, to be retained in the Bible we now know.

The scholarly consensus dates Revelation to AD95 or 96. Little is known of its author beyond the fact that he is certainly not the apostle John. The occasion of writing appears to be the persecution of Christians under the Roman emperor Domitian. Only a generation before, the Romans had sacked the Second Temple in Jerusalem and are, therefore, identified with the Babylonians who had destroyed the First Temple centuries earlier. The general purpose quite likely was to give hope and consolation to the faithful in the certainty that their tribulations would end, that the Kingdom of God would prevail. Ever since the influential 12th-century historian Joachim of Fiore, Revelation has been seen, within various traditions of gathering complexity and divergence, as an overview of human history whose last stage we are now in; alternatively, and this is especially relevant to the postwar United States, as an account purely of those last days. For centuries, within the Protestant tradition, the anti-Christ was identified with the Pope, or with the Catholic Church in general. In recent decades, the honour has been bestowed on the Soviet Union, the European Union, or secularism and atheists. For many millennial dispensationalists, international peacemakers, who risk delaying the final struggle by sowing concord among nations - the United Nations, along with the World Council of Churches - have been seen as Satanic forces.

The cast or contents of Revelation in its contemporary representations has all the colourful gaudiness of a children's computer fantasy game - earthquakes and fires, thundering horses and their riders, angels blasting away on trumpets, magic vials, Jezebel, a red dragon and other mythical beasts, and a scarlet woman. Another familiar aspect is the potency of numbers - seven each of seals, heads of beasts, candlesticks, stars, lamps, trumpets, angels and vials; then four riders, four beasts with seven heads, ten horns, ten crowns, four and twenty elders, twelve tribes with twelve thousand members ... and finally, most resonantly, spawning 19 centuries of dark tomfoolery, "Here is wisdom. Let him that hath understanding count the number of the beast; for it is the number of a man; and his number is six hundred, three score and six." To many minds, 666 bristles with significance. The internet is stuffed with tremulous speculation about supermarket barcodes, implanted chips, numerical codes for the names of world leaders. However, the oldest known record of this famous verse, from the Oxyrhynchus site, gives the number as 616, as does the Zurich Bible. I have the impression that any number would do. One senses in the arithmetic of prophecy the yearnings of a systematising mind, bereft of the experimental scientific underpinnings that were to give such human tendencies their rich expression many centuries later. Astrology gives a similar impression of numerical obsession operating within a senseless void.

But Revelation has endured in an age of technology and scepticism. Not many works of literature, not even the Odyssey of Homer, can boast such wide appeal over such an expanse of time. One celebrated case of this rugged durability is that of William Miller, the 19th-century farmer who became a prophet and made a set of intricate calculations, based on a line in verse 14 of the Book of Daniel: "unto two thousand and three hundred days; then shall the sanctuary be cleansed." Counting for various reasons this utterance to date from 457BC, and understanding one prophetic day to be the equivalent of a year, Miller came to the conclusion that the last of days would occur in 1843. Some of Miller's followers refined the calculations further to October 22. After nothing happened on that day, the year was quickly revised to 1844, to take into account the year zero. The faithful Millerites gathered in their thousands to wait. One may not share the beliefs, but it is quite possible to understand the mortifying disenchantment. One eyewitness wrote:

[We] confidently expected to see Jesus Christ and all the holy angels with him ... and that our trials and sufferings with our earthly pilgrimage would close and we should be caught up to meet our coming Lord ... and thus we looked for our coming Lord until the bell tolled twelve at midnight. The day had then passed and our disappointment became a certainty. Our fondest hopes and expectations were blasted, and such a spirit of weeping came over us as I never experienced before. It seemed that the loss of all our earthly friends could have been no comparison. We wept, and wept, till the day dawned.

One means of dealing with the disillusionment was to give it a title - the Great Disappointment - duly capitalised. More importantly, according to Kenneth Newport's impressive account of the Waco siege, the very next day after the Disappointment, one Millerite leader in Port Gibson, New York, by the name of Hiram Edson had a vision as he walked along, a sudden revelation that "the cleansing of the sanctuary" referred to events not on earth, but in heaven. Jesus had taken his place in the heavenly holy of holies. The date had been right all along, it was simply the place they had got wrong. This "masterstroke", as Newport calls it, this "theological lifeline" removed the whole affair into a realm immune to disproof. The Great Disappointment was explained, and many Millerites were drawn, with hope still strong in their hearts, into the beginnings of the Seventh Day Adventist movement - which was to become one of the most successful churches in the United States.

In passing, I note the connections between this church and the medieval sects that Cohn describes - the strong emphasis on the Book of Revelation, the looming proximity of the end, the strict division between the faithful remnant who keep the Sabbath, and those who join the ranks of the "fallen", of the anti-Christ, identified with the Pope whose title, Vicarius Filii Dei (vicar of the son of God) apparently has a numerical value of 666. I mention Hiram Edson's morning-after masterstroke to illustrate the adaptability and resilience of end-time thought. For centuries now, it has regarded the end as "soon" - if not next week, then within a year or two. The end has not come, and yet no one is discomfited for long. New prophets, and soon, a new generation, set about the calculations, and always manage to find the end looming within their own lifetime. The million sellers like Hal Lindsey predicted the end of the world all through the seventies, eighties and nineties - and today, business has never been better. There is a hunger for this news, and perhaps we glimpse here something in our nature, something of our deeply held notions of time, and our own insignificance against the intimidating vastness of eternity, or the age of the universe - on the human scale there is little difference. We have need of a plot, a narrative to shore up our irrelevance in the flow of things.

In The Sense of an Ending , Frank Kermode proposes that the enduring quality, the vitality of the Book of Revelation suggests a "consonance with our more naive requirements of fiction". We are born, as we will die, in the middle of things, in the "middest". To make sense of our span, we need what he calls "fictive concords with origins and ends. 'The End', in the grand sense, as we imagine it, will reflect our irreducibly intermediary expectations." What could grant us more meaning against the abyss of time than to identify our own personal demise with the purifying annihilation of all that is. Kermode quotes with approval from Wallace Stevens - "the imagination is always at the end of an era". Even our notions of decadence contain the hopes of renewal; the religious minded, as well as the most secular, looked on the transition to the year 2000 as inescapably significant, even if all the atheists did was to party a little harder. It was inevitably a transition, the passing of an old age into the new - and who is to say now that Osama bin Laden did not disappoint, whether we mourned at the dawn of the new millennium with the bereaved among the ruins of lower Manhattan, or danced for joy, as some did, in the Gaza Strip.

Islamic eschatology from its very beginnings embraced the necessity of violently conquering the world and gathering up souls to the faith before the expected hour of judgment - a notion that has risen and fallen over the centuries, but in past decades has received new impetus from Islamist revivalist movements. It is partly a mirror image of the Protestant Christian tradition (a world made entirely Islamic, with Jesus as Mohammed's lieutenant), partly a fantasy of the inevitable return of "sacred space", the Caliphate, that includes most of Spain, parts of France, the entire Middle East, right up to the borders of China. As with the Christian scheme, Islam foretells of the destruction or conversion of the Jews.

Prophecy belief in Judaism, the original source for both the Islamic and Christian eschatologies, is surprisingly weaker - perhaps a certain irony in the relationship between Jews and their god is unfriendly to end-time belief, but it lives on vigorously enough in the Lubavitch movement and various Israeli settler groups, and of course is centrally concerned with divine entitlement to disputed lands.

· Continues: Ian McEwan: The day of judgment, part two