Agony for agnostics agony: God's Funeral by A N Wilson John Murray, pounds 20, 402pp

As the sea of faith receded, late-Victorian free-thinkers looked forward to a century of peace and truth. Little did they know... Christopher Hawtree asks why reason's victory turned sour
Come that sad day when A N Wilson slots the front wheel into a cloud-capp'd cycle-stand and, crouched before St Peter, removes the clips from his shins, there will soon be a muttering from behind. Standard-issue humanity will have assumed this to be a five-items-or-fewer queue. They will not expect their entry into Paradise to be delayed by Wilson's metaphysical trolley-load.

No need to rehearse here his two decades of about-turns, in which one political party or other has won favour; Princess Diana has been the object of devotion and derision; and the pamphlet in which this Barbara Pym-buff announced a loss of faith was widely likened to Bob Dylan's going electric. Wilson should be appreciated for the multitudes he contains. He functions by being a contrary spirit.

That very contrariness makes Wilson leave in dusty obscurity his most jocular articles. In this study of the loss of faith and the rise of atheism in the 19th century, he prefers such observations as "there is perhaps no philosopher who has devoted a more agile or patient attention to the very bases of epistemology - that is, of how we can claim to know anything, the way that knowledge works - than Immanuel Kant (1724-1804)." Two pages on comes the assertion that "if you haven't read Kant before, I should strongly recommend that you avoid summaries or introductions to his work until you have given yourself a few weeks, let us say, to catch the quality of his mind at first hand."

That said, Wilson's half-dozen pages are done with such panache that one can almost picture beaches upon which the Critique of Pure Reason will oust John Grisham this summer. As he notes, Kant's effect was such that "some of the problems of philosophy were unanswerable. There had to be another way than metaphysics of understanding the world. Inevitably, this was physical science."

The 19th-century confrontation between science and religion is at the heart of a book which takes its title from a 1910 poem by Hardy. This dense, rueful mediation pictures the journey "toward our myth's oblivion,/ Darkling, and languid-lipped, we creep and grope/ Sadlier than those who wept in Babylon,/ Whose Zion was a still abiding hope." All those doubts a century and a half ago can now seem dry as dust, but Wilson - who describes this book as being "the story of bereavement as much as adventure" - can always bring ancient controversy alive.

He would have failed in his duty, however, if he inspired anybody to read Herbert Spencer, whose one memorable phrase - "the survival of the fittest" - is invariably taken to be Darwin's. But he quotes sufficent of that woolly, well-nigh surreal prose to show Spencer was a figure of clout in his time. Even as fine a mind as George Eliot was beguiled by him until she saw the true, comic figure depicted by Wilson, who displays further mischief when it comes to George Henry Lewes. "He was described by a contemporary (Douglas Jerrold) as `the ugliest man in London', and by a scholar of our own day as `a Victorian Clive James'".

Badinage, Wilson's mainspring, should not obscure his enormous reading. He finds a splendid parallel between Swinburne's giggling relations, the Mitford sisters, and the poet himself. Like Hardy, Wilson is sympathetic to the attractions of faith and never blind to the paradox that, in setting aside superstition, these thinkers hoped for a better world but did not live to see the one that turned out so much worse.

As Leslie Stephen did in the 1870s, Wilson goes back to the 18th century of Gibbon and Hume for the roots of Victorian dissent. Curiously, he gives only three pages to Stephen, Virginia Woolf's father. He does not go beyond Noel Annan's study of him to such essays as "The Religion of All Sensible Men" (which saw that even in enlightened circles "most disputants go into a modern line of battle armed with antiquated bows and arrows") and, above all, to "A Bad Five Minutes in the Alps". Here Stephen, in danger on a cliff edge, encapsulates these 19th-century spiritual dilemmas and - did he but know it - gives a glimpse of the turmoil into which he second wife's death would send him.

The irrationality of rationality - well caught by Woolf's portrayal of Stephen in To The Lighthouse - is a perennial paradox which Wilson treats in a conclusion which dwells unduly upon the strand of Catholicism known as Modernism. This is surely but an aspect of something Annan has elsewhere described as dashing the hopes of Stephen's kind of rationalist. It was the rise of nationalism, the consciousness of belonging to a special ethnic and linguistic community, which has made diplomacy in our time a nightmare and "rational" solutions to political problems unattainable.

The enormous power that nationalism was to have over men's minds was not foreseen by the thinkers of Stephen's time. Those who noted the phenomenon considered it to be an agreeable and worthy kind of loyalty.

Will this change "now that we don't have countries, only e-mail addresses", as Kenny Wheeler puts it? The success of Wilson's book is to make us, like Carlyle, fear not.