ISTANBUL — His career spans four decades, and Can Dundar said he has never seen a darker period for journalism in Turkey. His colleagues have been imprisoned, banned from traveling, accused of inciting hatred and aiding terrorists. Major Turkish media outlets, the ones that still exist, toe the government line.

Dundar himself now lives in exile in Berlin, publishing columns — in a series called “My Turkey” — critical of a government that will likely jail him if he returns home.

“They’d take me right off the plane,” said Dundar, the former editor-in-chief of a prominent Turkish daily who is accused of espionage and revealing state secrets.

This week, President Recep Tayyip Erdogan has pressed to fully investigate the killing of a high-profile Saudi journalist, Jamal Khashoggi, at Saudi Arabia’s consulate in Istanbul.

But journalists like Dundar and press advocates say that Erdogan’s demands for truth and openness in the case belie the strategy he has used — ruthlessly and effectively — in one of the world’s most sweeping crackdowns on press freedom. Some Erdogan critics note pointedly that Khashoggi, a former royal court insider turned Saudi government critic, fled his own country because of constraints on freedom of speech and diminished tolerance for dissent.

Though journalists in Turkey have long faced risks, they say Erdogan’s tactics in recent years have all but eliminated coverage that the government might dislike while pushing the country closer toward authoritarian rule. According to the Committee to Protect Journalists, Turkey jails more journalists than any other nation — more than China, Russia and Egypt combined. Earlier this year, a Turkish court sentenced six journalists and media employees to life in prison for alleged links to the U.S.-based cleric and Erdogan rival Fethullah Gulen, whom Ankara has said spearheaded a 2016 coup attempt.

But even for journalists who don’t face legal jeopardy, there are new hazards. After the thwarted coup, more than 100 broadcasters and other news outlets were ordered closed by a state decree, part of a massive purge of perceived Erdogan enemies. Other outlets have been converted into government cheerleaders after sales to pro-Erdogan businessmen or companies. Media members say they have had to weigh moral decisions about whether to remain in an industry that now serves as part of what one veteran journalist called the “propaganda machinery.”

“Journalism is in a deep coma in Turkey,” that journalist said, speaking on the condition of anonymity because he was reluctant to admit publicly that he was censoring himself. “There are taboos. I can’t write anything. It’s like the Twilight Zone.”

At a Bloomberg-organized forum last year, Erdogan responded to a question about imprisoned press members by saying, “Most of those you say are in prison aren’t journalists. Most of them are terrorists.” He added: “Saying ‘I’m a journalist’ doesn’t make you a journalist.”

For Erdogan, the media controls are one way to rein in a highly polarized country and head off additional crises. The coup attempt involved a bombing of the parliament building, left more than 200 dead, and highlighted the Gulen movement’s penetration of the military and state institutions. But Erdogan seized on the crisis to silence political opponents, as well. They were swept up in the post-coup purges and arrests, along with dissidents, journalists and innocent bystanders, human rights groups said.

Specifically in his handling of the Khashoggi case, Erdogan has seized on a chance to present himself as a truth-teller, weaken the rival Saudis and burnish Turkey’s international reputation, analysts say. Erdogan was said to have a personal relationship with Khashoggi, and they share some views about the place of Islam in politics. Speaking Tuesday, Erdogan described Khashoggi’s killing not as an attack against journalism but as a brazen crime committed within a diplomatic building — involving an attempted Saudi cover-up that should “hurt the conscience of all humanity.”

Authorities here have said that many Turkish media members who were charged or sentenced shouldn’t be considered journalists because they were engaged in activities beyond the scope of their profession. But journalists who’ve faced legal trouble say the evidence used against them tends to be the basic daily work of journalism: articles, messages exchanged with sources, even affiliation with a particular outlet.

In one prominent case, police acting on a court ruling in 2016 seized the offices of Turkey’s highest-circulation newspaper, Zaman, firing tear gas at protesters and placing the paper under state control. Zaman, which had been affiliated with the Gulenist movement, soon was shut down for good. This July, six of its former columnists and editors were sentenced to prison terms. Amnesty International called the convictions “absurd.”

Describing Turkey’s media landscape, Howard Eissenstat, a Turkey specialist at St. Lawrence University and a nonresident senior fellow at the Project on Middle East Democracy, said that on major issues “the [TV] channels are in lockstep.”

“This would be the equivalent of being in a country in which you had seven MSNBCs or seven Fox televisions, where you had news that was clearly supportive of the government on all the channels,” Eissenstat said.

The media crackdown has also had personal implications for journalists, including for Dundar, who until three years ago held one of the top jobs in Turkish journalism, as editor-in-chief of Cumhuriyet, a mainstream opposition newspaper. Dundar called the paper “one of the last free castles of the free media,” and in 2015, it published video and photos purporting to show weapons shipments from Turkey’s intelligence agency to Syrian rebels. Erdogan said soon after that Dundar would pay a “heavy price.” Months later, he was arrested, along with the paper’s Ankara bureau chief.

Dundar has since lived in legal limbo. He spent three months in pretrial detention. He won his temporary release. He escaped injury when shot at by an assailant who called him a “traitor.” (The assailant was arrested.) And in May 2016, he was sentenced to nearly six years in prison. He remained free to travel abroad while appealing that decision, and at the time of the coup, he was in Barcelona and working on a book. His lawyer suggested he not return, saying the courts couldn’t be trusted to hear his case. Dundar listened. Instead, he went to Germany.

“I had luggage full of books and summer clothes and nothing else,” he said.

He has tried to lead a low-profile life in Berlin. He says he is lonely. His wife has been barred from leaving Turkey. He takes precautions about his safety. Earlier this year, Turkey’s highest court said Dundar should in fact get a stiffer sentence — up to 20 years on espionage charges. At a news conference in Berlin with Chancellor Angela Merkel last month, Erdogan called Dundar a “spy” who had revealed “state secrets” and made a case for his extradition.

Dundar started an online news portal that was swiftly blocked in Turkey. In the meantime, he contributes columns for the Germany weekly Die Zeit, and he writes about many of the topics that journalists in Turkey can’t pursue, including corruption and press freedom. At times, he said, he feels more like an activist than a journalist.

“A freedom fighter, unfortunately,” Dundar said. “I say ‘unfortunately’ because it’s not the kind of journalism I wanted. But we were forced into it.”