ISTANBUL — As surely as dissidents have been locked up throughout Turkey’s turbulent modern history, their words — poems, memoirs, fiction and even screenplays — have managed to break out.

The country has a long tradition of literature written in prison, but the last few years have been especially fruitful. A frenetic crackdown by the government that has put thousands of people behind bars has set off a sullen publishing boom, with at least eight books penned by current or former inmates published in the last two years alone. 

One, a jailhouse diary by the novelist Ahmet Altan, has a title that evokes the hopeless length of his sentence: “I Will Never See the World Again.” Selahattin Demirtas, an imprisoned human rights lawyer and the former co-chair of Turkey’s second-largest opposition party, wrote a melancholy book of short stories that became a bestseller in Turkey and is being published by the actor Sarah Jessica Parker’s new literary imprint in the United States.   

As Turkey’s prison canon expands, the most recent books provide a glimpse of the country’s political tumult in the two years following a failed coup in 2016 against the government of President Recep Tayyip Erdogan. The authorities jailed tens of thousands of people they accused of aiding the coup or the PKK, an outlawed Kurdish militant group. Also swept up were journalists, opposition politicians and other critics as the government’s tolerance for dissenting voices evaporated.

At least six recent books were written by members of a mainstream pro-Kurdish political party, which has seen dozens of its members locked up or dismissed from their posts after being accused of links to the PKK. The party has denied any connection to the militants. In her book, Gultan Kisanak, a former co-chair of the party serving a 14-year sentence, interviewed other inmates by sending questions to their lawyers. 

The popularity of some of the works has shown the resilient appeal of prison literature in a country where a jail sentence has burnished the credentials of intellectuals and politicians and nearly everyone seems to have a favorite writer who served time.  

“Running alongside Turkey’s grand tradition of writing resistance is a grand tradition of reading it,” Maureen Freely, a writer and translator wrote in the introduction to the English-language edition of Demirtas’s “Dawn.” 

The book sold more than 200,000 copies in Turkey, according to the publisher. Amy Marie Spangler, who represents Demirtas and other authors from Turkey, said the actual size of Dawn’s readership was likely to be larger. It was sometimes hard to find in bookstores, but because of the author’s popularity, copies were passed around in Turkey, including among people who did not normally buy books, she said.  

In December, a photograph featured in Vogue of Parker carrying “Dawn” outside her West Village townhouse in New York circulated on social media and caused an uproar in Turkey for its suggestion that a figure the government had charged with spreading terrorist propaganda was being celebrated overseas. Demirtas, who has been detained since November 2016 and ran for president from prison, has denied the government’s accusations.

But the controversy over foreign support was nothing new. Pablo Neruda and other international artists had campaigned for the release of Turkey’s renowned poet Nazim Hikmet. In 1982, a jury at the Cannes Film Festival awarded its top honor to Yilmaz Guney, a Turkish filmmaker — for a film Guney had directed from jail. 

Over the decades, Turkey’s prison authors have been women and men, communists, leftists, Islamists and Kurds. Some of their books were banned in Turkey, and others have been bestsellers.  

Hikmet wrote prolifically during a 13-year stint in prison that ended in 1950. Sevgi Soysal won a prestigious Turkish literary award in 1974 for a novel she wrote in prison. Her prison memoirs were published two years later, when she died of cancer at the age of 40.

Necip Fazil, a writer and Islamist thinker who died in 1983, also wrote poetry during his many spells in prison. Erdogan, speaking last year at an award ceremony honoring Fazil, said: “The master was continuously subjected to the assassination of his character by certain circles just for being at peace with the values, the history, and the divinity of the nation.” 

Some of the recent books were written in longhand, on notebooks that inmates can purchase at prison canteens. Kadri Gursel, a Turkish journalist who served 11 months in prison beginning in October 2016, used his time inside to jot down thoughts for his latest book, which he wrote soon after he was released.  

The book, titled “I’m Sorry for You, Too,” is not strictly a prison memoir but rather a reflection on his life as a journalist in the context of Turkey’s growing “press freedom deficit,” he said in an interview. Gursel was part of a group of journalists and employees of Cumhuriyet, a Turkish opposition newspaper, who were arrested during the post-coup crackdown and accused of aiding a terrorist organization.  

In the book, prison is a prominent theme. As a teenage leftist, Gursel was first locked up shortly before Turkey’s military coup in 1980. He served almost four years in a series of military detention barracks, during a period in which more than half a million people in Turkey were also arrested. Years later, as a journalist, he was held captive by the Kurdistan Workers’ Party, or PKK, a Kurdish separatist group, for almost a month.  

Drawing on those experiences, he wrote recommendations in his book for other journalists, should they find themselves behind bars. It was necessary, he wrote, to increase one’s “suffering threshold to the highest possible level, in order to get out of jail with minimal damage to the body, mentally and physically.” The strongest prisoner, he added, “is the one who succeeds in not missing the things he loves.” That did not mean forgetting life on the outside, he added, but rather, not thinking about it. 

“It is knowing how to expel an uninvited thought,” he wrote. 

Altan did not bring the book to his longtime Turkish publisher because of the current political climate, according to his friends, but it was published last week in the United Kingdom and will be released in the United States by Other Press in the fall.  

He is serving a life sentence without the possibility of parole after being convicted of “trying to overthrow the constitutional order.” Prosecutors had accused Altan of sending subliminal messages to the coup plotters during a television appearance the night before the failed coup. 

Human Rights Watch said the case against him was “politically motivated” and set a “frightening precedent” for press freedoms. His case is under appeal.   

“I can write anywhere — sound and movement don’t distract me,” he wrote in his book. “I go into an invisible room all by myself and cut off my ties with the rest of the world.” Altan sent the essays that formed the book out of prison with his lawyer, over the course of seven months.   

“You can imprison me but you cannot keep me here,” he wrote in the book’s final passage. “Because, like all writers, I have magic. I can pass through your walls with ease.”