The Indian historian Ramachandra Guha has launched the second volume of his two-volume biography of Mohandas K(Mahatma) Gandhi, a magnificent achievement that, in Guha’s words, has taken “30 years of unsystematic interest and 15 years of obsessive foraging”. At a talk last week at the London School of Economics, he was passionate and amusing, and it was uplifting to hear his respect and affection for one of the great moral figures of the last century. The questions from the audience mainly concerned Gandhi’s role in the independence movement and his attempts to heal India’s religious and social divisions. But then – a last question – a young woman wondered about a strange episode in Gandhi’s life that she found “unsettling”. In reply, Guha went further; it had been “inexplicable and indefensible”.

For several decades after his death, this episode was not widely known. Popular accounts of Gandhi’s life, including Richard Attenborough’s biopic, never mentioned it. The facts are that after his wife, Kasturba, died in 1944, Gandhi began the habit of sharing his bed with naked young women: his personal doctor, Sushila Nayar, and his grandnieces Abha and Manu, who were then in their late teens and about 60 years younger than him.

Gandhi hadn’t had a sexual relationship with a woman for 40 years. Nor, in any obvious way and so far as anyone can tell, did he begin one now. His conscious purpose in inviting naked women to share his bed was, paradoxically, to avoid having sex with them. They were there as a temptation: if he wasn’t aroused by their presence, he could be reassured he’d achieved brahmacharya, a Hindu concept of celibate self-control. According to Gandhi, a person who had such control was “one who never has any lustful intention, who by constant attendance upon God has become proof against conscious or unconscious emissions, who is capable of lying naked with naked women, however beautiful they may be, without being in any manner sexually excited”. Such a person, Gandhi wrote, would be incapable of lying or harming anyone.

Why was this so important to Gandhi at that time? Because he believed – fantastically, egotistically – that the Hindu-Muslim violence then sweeping India had some connection to his own failings. He had come round to the view, as Guha writes, “that the violence around him was in part a product or consequence of the imperfections within him”. And those imperfections, which he scrupulously recorded and publicised, included the “nocturnal emissions” (wet dreams) that had occurred in the years 1924, 1936 and 1938 to spoil a record of celibate living that began in South Africa in 1906, and which led each time to bouts of self-disgust.

The assassination of Mahatma Gandhi: from the archive, 31 January 1948 Read more

He believed sex existed only to procreate and never to enjoy, a view that his political ally Jawaharlal Nehru found “unnatural and shocking”. Lust was the enemy; that lesson was learned when, as a married 16-year-old, he had left his sick father’s bedside to be with his wife and, as they made love, his father had died. As to any unconscious motivation for bed-sharing, who knows? As one of the world’s most famous men, a magnetic celebrity, he rarely hesitated to exploit his attraction to women in order to benefit from the help and care they offered. In his ashram, the psychoanalyst Sudhir Kakar has written: “The competition among women for Gandhi’s attention was as fierce as it is in any guru’s establishment today.”

His behaviour in the winter of 1946-47 shocked many of his followers. At least two of his helpers, his stenographer and his Bengali translator, quit his service in protest when they discovered that he was sleeping with 19-year-old Manu. The Indian press stayed silent. Unusually, Gandhi kept his “experiment” with Manu reasonably private – behaviour that he later regretted because it violated the principle that the seeker after truth must keep nothing hidden.

No evidence suggests the young women themselves bore Gandhi any ill will. Manu and Abha were walking at either side of him – they were known as his “walking sticks” – when his assassin ran forward with a pistol in a Delhi garden in January 1948, a year after he brought his experiments in celibate sexuality to a close.

The fond name for Gandhi was Bapu, meaning father, but a short memoir that Manu wrote later is titled Bapu – My Mother, a contradictory phrase that at first sight is an odd way to describe a man who has used you as a test of his desire. In fact, her mother had died when she was a child. Gandhi’s wife had adopted her and, when she died in turn, Gandhi assumed the maternal role. He cooked and cared for her, and Manu noted in her diary that his conversation “was filled with affection greater than any mother could feel”. But there was more than simple familial duty at work here. Gandhi often liked to say he was half a woman: in the words of another historian, Vinay Lal, “it is almost plausible to speak of Gandhi’s vulva envy”. He liked to play with sexual boundaries. In this, as in his environmentalism, his diet and his techniques of protest, he prefigured our age.

Arun Gandhi: ‘My grandfather saw my anger as fuel for change’ Read more

To dislocate phenomena from the present to the past is usually pointless. Does anyone care how Shakespeare would have voted in the EU referendum? Nonetheless, it’s interesting to consider how our present moral temperament would have reacted to the news of Gandhi’s experiments. A powerful old man, subordinate young women, nudity: he would surely have been widely reviled, and his faults distorted and oversimplified in the rush to judge him. A blot on his reputation would have become enormously magnified – a sad end to a humane and world-changing life.

In this circumstance, George Orwell might never have written the epitaph that Guha repeats in his final pages – the fact that: “Compared with the other leading political figures of our time, how clean a smell he has managed to leave behind!”

• Ian Jack is a Guardian columnist