When Memoirs of Hadrian was published in 1951 it included a postscript in which its author, Marguerite Yourcenar, explained why she had fixed on the 2nd century AD as the setting for her novel. “Just when the gods had ceased to be, and the Christ had not yet come, there was a unique moment in history, between Cicero and Marcus Aurelius, when man stood alone.”

These words were not her own, but a quotation from Flaubert, whose aestheticisation of atheism was deeply appealing to Yourcenar and had exercised a strong influence on her portrayal of Hadrian. Flaubert in turn was heir to assorted philosophes, libertines and natural philosophers whose daring rejection of Christian orthodoxies had been much seasoned with allusions to classical precedents. Voltaire, in a celebrated early poem, had consciously modelled himself on the Roman poet Lucretius, whose materialism and contempt for religion had been exciting freethinkers ever since the rediscovery of his masterpiece On the Nature of Things back in the Renaissance. “How admirable he is,” Voltaire wrote, “in his encomia, in his descriptive passages, in his ethics, and in all his criticisms of superstition.”

Nowadays, when the place of classics in the school curriculum is a spectral shadow of what it was in Yourcenar’s time, let alone during the Enlightenment, there are few atheists in the habit of looking back to Lucretius to sustain their own scepticism. Indeed, Tim Whitmarsh worries there are many who believe that atheism is an exclusively modern phenomenon, a fruit of the 18th century. But few scholars are better equipped to combat this misapprehension than he. Although his specialisation is the culture of the very period that Flaubert identified as the one “when man stood alone”, his appointment to the professorship of Greek culture at Cambridge in 2014 was due recognition of his mastery of the whole sweep of ancient history. Thus, unsurprisingly, his new book on atheism in the ancient world is as learned as it is intellectually thrilling. Covering the millennium and more that separates Homer from Theodosius the Great, Battling the Gods fills a gap that probably few of us had even been aware of, and does so comprehensively.

Naturally, there are starring roles for the particular heroes of the Enlightenment: Lucretius, of course, but also Epicurus, the Greek philosopher who first inspired On the Nature of Things, and whose atomistic vision of the universe delighted scientists in the 17th century. Other great names from antiquity are placed in eye-opening perspective by Whitmarsh’s narrative. Thucydides, whose project of explaining human affairs without reference to divine interference provides historical practice today with its ultimate model, is given due acknowledgement for his originality and boldness. His account of the Peloponnesian War, Whitmarsh writes, “can reasonably be claimed to be the earliest surviving atheist narrative of human history”.

The great Athenian tragedians, too – despite the gods and prophecies that frequently featured in their plays, and the religious festival that provided the setting for performances of drama notwithstanding – are shown to have been fascinated by atheistic ideas, if not necessarily atheists in their own right. Most notably, Euripides, whom Aristophanes openly accused of promoting disbelief in the divine, repeatedly portrayed his heroes as ruined by their trust in the beneficence of the gods. A play such as The Trojan Women, in which the women of fallen Troy struggle fruitlessly to find meaning in the annihilation of their city, is one where atheism comes to seem almost a palliative. “O vehicle of the earth and possessor of a seat on earth,” Hecuba, the Trojan queen, prays, “whoever you are, most difficult to know, Zeus, whether you are the necessity of nature or the mind of men: I offer you my prayers.” Predictably, Zeus does not answer her; and, throughout the play, misery follows swift upon misery. Either the gods do not exist or else, like wanton boys, they kill for sport.

The most revelatory aspect of Battling the Gods, however, is a product of Whitmarsh’s detective work in tracing lines of evolution from the first philosophers to the networks of atheists which, he convincingly demonstrates, had come to exist across the Roman empire by the time of its heyday in the 2nd century AD. A few decades after the death of Hadrian, a philosopher named Sextus listed the most prominent atheists in history, but the only one whose influence was destined to endure into the Enlightenment was Epicurus.

Doubly condemned to oblivion, first by their more god-fearing contemporary opponents and then by Christians, philosophers who promoted disbelief in the supernatural rarely survived as much more than a name. Whitmarsh’s accomplishment is to give to some of these ghosts at least a semblance of solidity. When he hails Diagoras of Melos as “the first person in history to self-identify in a positive way as an atheist”, or describes Clitomachus, a sceptic from Carthage who ended up leading a philosophical school in Athens, as “that prodigious figure in the history of atheism”, it is a measure of his scholarship that we are able to accept the force of these descriptions. The great achievement of Battling the Gods is to trace in a manner that can be followed readily the evolution of sceptical attitudes towards the divine across the whole span of ancient history.

Nevertheless, Whitmarsh is too good a scholar not to acknowledge that the fragmented and ambivalent nature of the evidence is such that it remains hard to pin down the precise character of disbelief in antiquity. His own preference is to emphasise the similarities between ancient and modern atheism, and to see Clitomachus and Lucretius as the forebears of Richard Dawkins and Sam Harris. Although Whitmarsh declares in his preface that it is not his aim “to prove the truth (or indeed falsehood) of atheism as a philosophical position”, his distaste for theism is evident throughout the book, as is his admiration for the ancient philosophers who dared to battle it. “Atheism, in my opinion,” he declares, “is demonstrably at least as old as the monotheistic religions of Abraham.” This is to cast it as the equivalent of Judaism or Christianity; a recognisably coherent tradition that has evolved unbroken over the millennia, so that Christopher Hitchens can be viewed as the heir of Diagoras and ancient philosophy as the seedbed of modern secularism. In other words, atheists no less than believers can feel pride in the sheer pedigree of their beliefs.

Yet it is possible, even in the light of this book, to interpret ancient atheism in a rather different way. The more we know about those philosophers whom the ancients described as atheoi, the less like contemporary sceptics they seem. Epicurus, for instance, though he featured in Sextus’s list of famous atheists, not only believed in gods but was an initiate of the local mysteries, and went as far as to demand sacrifices from his followers “for the care of my holy body”. His materialist convictions were not, as his 17th-century admirers liked to imagine, bred of a scientific cast of mind, but of the precise opposite: a conviction that they would help him to attain inner peace. The only value of research into the natural world, so Epicurus believed, was to enable the philosopher, by properly appreciating the pointlessness of superstition, to attain the state of tranquillity that was, so he taught his disciples, the ultimate goal of life. The closest modern parallel is probably not Richard Dawkins but rather Maharishi Mahesh Yogi.

That there are Catholic and Protestant atheists is an old joke. The lesson that Whitmarsh teaches in Battling the Gods – though it is one he seems reluctant to draw for himself – is that there are monotheist and non-monotheist atheists, too, and that they are often very different beasts. When he claims that belief in the supernatural has been shadowed throughout history and across the world by disbelief, he may well be right; and yet, if so, the implication is that atheism, in its origins and manifestations, is just as likely to be multiform as is religion. Epicurean atomism may have intrigued Robert Boyle and Isaac Newton, but it did not inspire their scientific breakthroughs, which derived from very different causes, and in the context of a world-view that was decidedly Christian.

To draw on a fittingly Darwinian analogy, ancient atheists and their modern successors resemble one another in the way pterosaurs resemble bats: an example of similar features developing in unrelated species. Whitmarsh may not have intended it to do so, but Battling the Gods – learned, sweeping and stimulating as it is – stands as a monument above all to that recurrent phenomenon in history, convergent evolution.

Tom Holland’s most recent book is “Dynasty: the Rise and fall of the House of Caesar” (Little, Brown)

Batting the Gods: Atheism in the Ancient World by Tim Whitmarsh is published by Faber & Faber (304pp, £25)