It is difficult to say which was worse, the physical torture or the excruciating tricks my captors played on my mind. They showed me printouts of Twitter posts to convince me that I had been forgotten. They shared agonizing details of how easy it would be to target my mother, how vulnerable my family was. They showed me a picture of my wife on a pilgrimage in Mecca and claimed she was a hypocrite feigning piety. They showed me my sister’s tweet on Nelson Mandela’s death and said it represented fealty to an infidel. My brother’s photograph at a social event was proof of my family’s errant ways. But this “evidence” gave me strength. I knew that my family was well, and that they, and many others around the world, were thinking of me and praying for my safety and release.

Solitary confinement, loneliness, doubt and anxiety can do strange things to your mind. You start questioning your sanity. The faces that you have loved so much recede into darkness; voices that you heard so often fade into obscurity. But memory has its own magic. I could not go home, but I could bring my home to me. In my mind I visited familiar places. I conjured up my boisterous friends, one by one, and imagined myself to be a stand-up comedian and developed comedy routines for each friend. These practiced routines are now coming in handy as I see my friends again.

There were some 30-odd months when I had brief, unmonitored, almost surreal contact with the outside world. One of my guards, like myself, was a Manchester United fan, and every other week he would sneak a radio into my cell and we would listen to soccer games. For him, this was an illicit pleasure. He believed that playing or even listening to soccer was a sin. For me, it was a window to the outside world. Getting soccer news kept me sane. “You must surely be the only United fan in this position,” I would tell myself. “They are playing and winning for you.”

Looking back, I can see that I was always free. No one can imprison you except yourself. My abductors could make my life intolerable, but as long as I held on to my sanity, I was liberated. I was in God’s hands, not theirs, and I knew that He would protect me and take me home. He did. He worked miracles: I survived drone strikes and war, I lived through multiple illnesses without treatment, I was shot, mentally and physically tortured, I lived in abysmal living conditions, and survived the rout of the I.M.U. by the Afghan Taliban in November 2015.