Karen Armstrong is one of the handful of wise and supremely intelligent commentators on religion who has become distressed by the tone of recent discussions of the subject. Her targets are religious fundamentalism on the one hand and militant atheism on the other: in other words, al-Qaida as well as Richard Dawkins. In plain language, and nowhere more eloquently than in this new book, Armstrong accuses both factions of misunderstanding the nature of God and, interestingly, of doing so in similar ways.

Both atheists and fundamentalists take God to be an essentially human sort of figure, a giant Father in the sky who watches over us, punishes the guilty, intervenes directly in our affairs and is entirely comprehensible to our minds. "We regularly ask God to bless our nation, save our queen, cure our sickness or give us a fine day for a picnic." Fundamentalists commit, in Armstrong's view, the grave error of presuming to know God's mind and also of enlisting God on their side against their enemies. Unsurprisingly, militant atheists observe this reductive vision of God and in turn slam religion as a child-like description of the world that cannot compare with the subtlety and practical powers of science.

Armstrong's new book is shaped as a response to these two distortions. She wishes to remind us of the mystery of God. Her sympathy is with the great Jewish, Christian and Muslim theologians who have denied that any human attempt to put the divine into words will be accurate. We are simply too limited to be able to know God; our apprehension must hence be suffused with an awareness of our provisional and potentially faulty natures. She writes: "He is not good, divine, powerful or intelligent in any way that we can understand. We could not even say that God 'exists', because our concept of existence is too limited."

Much of Armstrong's book is spent pointing out the deep-seated needs that religions have traditionally addressed. She begins in the caverns of Lascaux in the Dordogne and argues that the early religious rites to which the famous animal pictures belonged were connected with our ancestors' wish to atone for the overbearing guilt that came from having to butcher other living creatures for survival. Like art, religion has been a way of containing feelings that might otherwise tear individuals and societies apart. Armstrong leans heavily on the distinction first made by the ancient Greeks between the realms of mythos and logos. Logos is "a pragmatic mode of thought that enables people to function effectively in the world"; it is what we rely on when organising society or planning a journey. However, logos has its limitations: "It cannot assuage human grief or find ultimate meaning in life's struggles." For this, there is the realm of mythos or myth, to which religion and art belong. Religion offers us moments of what Armstrong calls, using another Greek term, ekstasis, a stepping outside of the norm for the sake of release and consolation.

Aside from helping us to deal with our feelings of fear, aggression and guilt, religion is also defended by Armstrong as a source of compassion. She recounts the story of a man who once came to see the great Rabbi Hillel and asked if he might undertake a rigorous course of study of the Torah with him. Hillel waved him away: "What is hateful to yourself, do not to your fellow man. That is the whole of the Torah and the remainder is but commentary. Go learn it." Armstrong traces the emphasis on compassion across the major religions. There are fascinating discussions here of the Buddhist state of "anatta", or no self, a desirable condition that can be reached only through extensive meditation. It can lead us, for brief periods, to look at the world as though we were not ourselves participants in it, and therefore free us from our noxious impulses to pass judgment and to presume that we know why other people have acted the way they have.

The concluding part of Armstrong's book traces the growth of modern atheism and attributes it largely to religions' failure to argue for what is most compelling about them. Fatally, religions tried to defend themselves against science by arguing that they knew the truth better than the geologists, rather than presenting themselves (as one feels Armstrong would have wished) as the guardians of mystery and therapeutic manoeuvres of the mind.

A melancholy tone sometimes makes itself felt in this book, as one senses the author defending religion from its own worst impulses. As a former nun, Armstrong's perspective is unique in its combination of sympathy and lack of sentimentality towards religion's wilder and more immature claims. She joins Richard Holloway and Charles Taylor as one of the most intelligent contemporary defenders of religion, making a case that scrupulously avoids reliance on the supranatural. As in so much of the rest of her hugely impressive body of work, Karen Armstrong invites us on a journey through religion that helps us to rescue what remains wise from so much that to many in Britain today no longer seems true.

• Alain de Botton's most recent book is The Pleasures and Sorrows of Work (Hamish Hamilton).