Despite serving as Oxford university's professor for the public understanding of science for 13 distinguished years, his work as an ethologist and evolutionary biologist, not to mention his many books, Richard Dawkins remains most celebrated as a latter-day atheistic Savonarola, forever seeking to make a bonfire of what are, to him, the vanities and idiocies of religion. Less well known is his fondness for penis gags.

Until he faced the recently retired Archbishop of Canterbury at the Cambridge Union Society a little after 8pm on Thursday night, few would have expected the debate between two such great and different minds to lurch into the arena of genital humour. The last time the pair met, almost a year ago in the Sheldonian theatre – a touch of Oxonian yin to the Cantabrigian yang; the balance of the universe must, after all, be respected – the encounter was disappointingly good natured and civilised, raising the very real, if dull, possibility that the two men might actually not despise one another.

Still, that was another life ago for Lord Rowan Williams. Free of the mitre and the pressure of being leader of the world's 77 million Anglicans, would the newly appointed master of Magdalene College, Cambridge, prove a more implacable opponent on his home turf? Not so much. Speaking in opposition to the proposition that organised religion has no place in the 21st century, Williams was his usual calm, scholarly self.

"Religion," he said, "has always been a matter of community building; a matter of building precisely those relations of compassion, fellow feeling and – I dare to use the word – inclusion, which would otherwise be absent from our societies." The main historic religions of the world, he added, had all shown a compassionate and metaphysical commitment to equality and to helping those "at the very edge of their society". But that wasn't to say "communal religion" did not deserve to be scrutinised. Reaching simultaneously into his reserves of Christian charity and sarcasm, the former archbishop looked at his opponent and added: "That is why if I say I thank God for Professor Dawkins, you will understand what I do and I don't mean."

Dawkins himself was, characteristically, rather less measured, deciding to kick off with a provocative, personal reinterpretaton of St Paul's first letter to the Corinthians. Despite being brought up in the Anglican tradition, he said, he no longer "spake as a child" and had long since put away such "childish things" as belief in a deity. Christianity duly slapped down, he moved swiftly on to Islam.

"If I were a cultural Muslim," he said, "I would have something to say about that faith's appalling treatment of women – its appalling attitude to women – as well as various other moral points."

Then came Dawkins' rhetorical ace. Clearly well-attuned to student audiences, the scientist made an apparently passing reference to God as "the immortal knob-twiddler". For this, the author of The Selfish Gene and The God Delusion, one of the most respected scientists on the planet, was rewarded with a roar of laughter and a crackle of applause that echoed around the chamber for a full 10 seconds. The other speakers, Andrew Copson of the British Humanist Association, the Cambridge philosophy lecturer Dr Arif Ahmed, the Islamic scholar Tariq Ramadan and Douglas Murray of the Henry Jackson Society, were always going to struggle to top that.

Dawkins may have gone on to rail against religion as "a cop-out; a betrayal of the intellect; a betrayal of all that's best about what makes us human", and proclaimed it time to consign its "obscurantist interference with the search for truth" to history. He may ultimately have lost the debate by 324 votes to 136. But no matter: a career in stand-up could yet beckon for the 21st century's Savonarola, who very nearly had his audience at "knob-twiddler".