A Turkish court has reversed its decision to release from detention the local head of human rights group Amnesty International, the group says.

Detained in June, Taner Kilic has been charged with membership of a terrorist organisation, which he denies.

London-based Amnesty says the decision is a "travesty of justice". It has called the accusations "baseless".

Mr Kilic's arrest was part of a crackdown after the failed coup attempt of June 2016.

How was his release reversed?

During a hearing on Wednesday, the court in Istanbul ordered the conditional release of Mr Kilic from a prison in western Izmir province.

A prosecutor appealed against the decision, Amnesty said, and a second court accepted it. On Thursday, the first court accepted the second court's decision to continue his detention.

"This is the latest example of the crisis in Turkey's justice system that is ruining lives and hollowing out the right to a fair trial," Amnesty's Secretary General Salil Shetty said in a statement.

"To have been granted release only to have the door to freedom so callously slammed in his face is devastating for Taner, his family and all who stand for justice in Turkey."

The next court hearing has been set for 21 June, the group added.

What is the case about?

Mr Kilic was accused of using an encrypted messaging application called Bylock that the Turkish government said was used by followers of the US-based Islamic preacher Fethullah Gulen.

President Recep Tayyip Erdogan accuses Mr Gulen of being behind the 2016 coup attempt - a charge the cleric denies.

Amnesty said two independent forensic analyses of Mr Kilic's phone found that there was no trace of the application ever having been on his device.

Ten other activists, who were released last year, are also on trial, including the director of Amnesty's Turkey office, Idil Eser, a German and a Swede. They deny the charges and face up to 15 years in jail.

Critics of the government say there has been a steady erosion of judicial independence in Turkey, as courts feel unable to stand up to the authorities, the BBC's Mark Lowen in Istanbul reports.

More than 40,000 people were arrested and 120,000 sacked or suspended from their jobs in the aftermath of the failed coup. They include police, military personnel, teachers and public servants.

Amnesty has been a vocal critic of the crackdown on suspected coup plotters. It said in 2016 it had "credible reports" of detainees being subjected to "beatings and torture, including rape".