I was at primary school in Kabul during the Soviet occupation. One day, seemingly out of the blue, a Muslim girl started a campaign of fear and slander against our only Jewish classmate. She declared that the latter came from a morally loose household and incited us to ostracise the quiet blonde girl. As far as we could see, there was nothing outwardly immoral about this exceptionally smart girl who already kept herself to herself. We asked the inciter to explain her accusation and she responded: "Her mother lets in a complete stranger, a man, into their house every Sabbath!" The understanding was that no decent Afghan woman would allow a strange man into her home, especially if she was a widow with no grownup son to protect her honour. This example of ignorance breeding cruelty took place at the honeymoon stage of the Afghan flirtation with jihad – before the mass romance with God's soldiers turned into gang rape.

Looking now at old photographs of family life, religious classrooms and bar mitzvahs, the similarities between Muslim and Jewish Afghans are striking. The rabbis' beards, turbans and gowns made them almost indistinguishable from Muslim scholars, while both were referred to by the title of mullah. The community shared with the rest of society a profound mistrust of state interference in family affairs, rejecting secular education and military service. In the 1920s, Jewish rabbis famously protested against Kabul's attempt to enlist Jewish children to state school.

Much like the rest of society, the family structure was patriarchal. Jewish women married young, were deprived of education and led domestic lives away from the public eye. When leaving home, they covered themselves just like their Muslim counterparts. Such resistance to change meant that the community remained conspicuously traditional and closely knit together, marrying only among themselves. In the later decades, when Jewish children started to attend state schools, they had no choice but to turn up to classes on Sabbath. They dealt with this problem by simply sitting down but not doing much else. But this religious tolerance was already disappearing by the time of the Soviet occupation, when I had my own first-hand experience.

But I learned later that my experience of Afghan intolerance of Jews was far from representative. From a historical perspective, the story of the Afghan Jews is a tale of remarkable tolerance. It may seem hard to believe today, but historically it was Afghanistan to which Jews turned to when escaping religious persecution in Iran and central Asia. It was in the dusty, ancient cities of Herat and Kabul, to the west and the east of Afghanistan, that they found freedom to practise their faith without getting murdered in the process. A community of leather and karakul merchants, poor people and money lenders alike, the large Jewish families mostly lived in the border city of Herat, while the families' patriarchs travelled back and forth on trading trips, moving between Iran, Afghanistan, India and central Asia on the ancient silk road.

The Jews did not engage in farming, which restricted their means of earning a living. Like many other Afghans, they survived through trade, taking lengthy and often dangerous trips across the majestic mountains on whose rocks their prayers were carved in Hebrew and sometimes even Aramaic.

Like the rest of the population, the Jews of Afghanistan were simultaneously local and transnational, rooted to the Afghan soil by birth and burial but connected to a global faith through religion. Like Afghan Hindus and Muslims, their sacred sites, too, were located in faraway, hard-to-reach places while their holy language was not the official language of the nation. Isolated and yet connected through the invisible ties of spirituality, Afghan Jews were much like the rest of Afghans, sharing with the Sunni Pashtuns in particular a belief in being descended from the biblical lost tribes. Such similarities were ultimately why a peaceful coexistence was possible between Jewish and Muslim Afghans for most of their shared history, which dates back to the medieval times.

The Afghans' isolation from the rest of the world was a blessing in disguise for the Jewish community because being cut off from global political trends meant that ordinary Afghans were untouched by the raging, European-led, antisemitism of the early 20th century. Even at the height of the Nazi influence in Kabul of the 1930s, it was Afghan nationalism rather than antisemitism that led the government to introduce economic measures that bankrupted Jewish money-lending families.

The laws affecting the Jewish community were soon removed and in the following decades Afghanistan was the only Muslim country that allowed Jewish families to immigrate without revoking their citizenship first. When Afghan Jews left the country en masse in the 1960s, their exile to New York and Tel Aviv was motivated by a search for a better life but not because of religious persecution.

Like most Afghans, the Jewish community was also polyglot, reading Hebrew and speaking the local language as well as their own Judeo-Persian dialect. Largely illiterate, the community transmitted knowledge and wisdom through oral folktales, the Kafkaesque surreal characters and narratives of which are much like other Afghan folktales. A brutal truth of the cruelty of life in Afghanistan, for example, is summed up at the end of the Jewish folktale Moses and the Ants: "When the fire rages in the wood, it burns the bad trees and the good."

Now all are burned.

• Follow Comment is free on Twitter @commentisfree