My father, Ahmad Shams, a doctor, writer and political activist, who has died aged 97, was twice imprisoned in his home country of Iran before eventually resettling in the UK. Having spent his life campaigning for democracy and equality, Ahmad treasured what Britain gave him. He admired the NHS as a socialist venture made real, and he took part in British democracy with real pride, voting in every general election.

It was in London that he completed his six-volume history, Struggle for Freedom and Independence in Iran, spanning the eve of the Arab conquest to 2009. Published anonymously and freely online in Farsi, it reflected his belief that knowledge belonged to everyone.

Born in Tabriz, Iran, Ahmad was the son of Zahra-Soltan and Ghassem, the official dentist to the Qajar crown prince’s court. Ahmad’s elder brother Ismail was one of the leaders of the Soviet-backed Azerbaijan People’s Government (1945-46), a briefly autonomous state inside northwestern Iran. Inspired by his brother, Ahmad, who went to Ferdowsi school in Tabriz, joined Iran’s communist Tudeh party in his early 20s, but challenged its subservience to Moscow and was expelled. Nevertheless, he remained a socialist, on his own terms.

He studied medicine at Tabriz University, and in 1953 married Najibeh Farajpour-Azar. After the coup that overthrew the elected prime minister of Iran that year and restored the shah to power, Ahmad was imprisoned for his political activities for six months. He continued his medical studies behind bars, and shortly after his release opened a surgery, treating poorer patients for free.

In 1970 Ahmad qualified as a paediatrician at Tehran University, and continued to write and publish anonymously on ideas of democracy and equality. While in Paris taking a course in paediatric respiratory medicine, he published The Past Is a Lamp Lighting the Path to the Future (1977), a chronicle of Iranian history between the coups of 1921 and 1953.

When the 1979 revolution that overthrew the shah led to the establishment of another dictatorship, the Islamic Republic, Ahmad organised resistance. Arrested and sentenced to death in 1981, he survived because the prisons needed doctors, and was released after six years. He resumed practising medicine until his late 60s.

In 2000 he left Iran with Najibeh to join their sons in Uxbridge, west London. In 2012 they moved to Richmond. During this time Ahmad worked on his last and largest piece of work, the study of Iran’s struggle for freedom, which he published online in 2023.

Najibeh died in 2021. Ahmad is survived by their two daughters, Solmaz and Golnaz, and two sons, Siamak and me, and by nine grandchildren.