ANKARA (Reuters) - Turkish journalist Mehmet Altan was released from prison on Wednesday, one of his lawyers said, four months after he was jailed for life on charges of aiding plotters behind a failed military coup.

Slideshow ( 3 images )

Earlier in the day an Istanbul appeals court ordered that he be freed from the city’s Silivri prison.

Altan’s brother Ahmet and four other journalists were also sentenced to life in the same case and remain behind bars.

The Altan brothers were detained in September 2016 as part of a government crackdown following the July 2016 coup attempt against President Tayyip Erdogan.

Mehmet Altan was sentenced in February even though the constitutional court, Turkey’s highest, had previously ruled for his release, saying that his detention amounted to a violation of his rights. A penal court rejected that request and decided to keep him in jail as his trial continued.

“It was an absurd situation and totally unlawful for him not to be released after the Constitutional Court decision,” the lawyer for Altan, who declined to be named, told Reuters earlier.

“Another court, the appeals court, did the right thing and released him now. That’s what should have happened in the first place,” the lawyer said.

Altan’s case underscored deep concern about press freedom in Turkey as well as worries over the independence of the judiciary under Erdogan, who was re-elected on Sunday to a newly empowered executive presidency.

The court ruled that the other five defendants in the Altan case be remanded in jail.

Since the coup attempt, more than 50,000 people have been jailed and 150,000 sacked or suspended from their jobs.

More than 120 journalists have been detained and over 180 media outlets closed on suspicion of links to the network of U.S.-based cleric Fethullah Gulen, blamed for organizing the abortive attempt to topple the government. He denies any connection with the would-be coup.

Ahmet Altan was charged over comments he made the day before the coup attempt, when he told a television show: “Whatever the developments were that led to military coups in Turkey, by making the same decisions, Erdogan is paving the same path”.

On the same program, Mehmet Altan referred to “another structure” within the government that was closely watching developments to “take its hand out of the bag”.

Turkey’s military has staged a number of coups or interventions in politics in the past.

Prosecutors said that the brothers’ comments were coded messages to Gulen’s followers to take action.