Hours after he was acquitted by a court and freed after more than two years in jail, a high-profile Turkish philanthropist was rearrested on separate charges in a case that has raised questions about the rule of law in Turkey.

A surprise court decision on Tuesday to drop charges against Osman Kavala, 63, and eight other defendants, of undermining Turkey’s national security by taking part in the 2013 Gezi park anti-government protests prompted applause in the courtroom.

Even pro-government circles and supporters of Turkish president Recep Tayyip Erdogan voiced quiet relief that a court case based on little evidence – and one which had drawn scrutiny from diplomats and international advocacy groups – was finally concluding.

But Mr Kavala’s rearrest later on Tuesday, on fresh accusations that he participated in a deadly failed 2016 coup attempt, allegedly perpetrated by the spiritual movement of exiled religious scholar Fethullah Gulen, dashed those hopes.

“It was Erdogan who ordered the arrest of Kavala, and it was he who ordered his release today,” pro-Kurdish Peoples’ Democratic Party (HDP) lawmaker Garo Paylan was quoted as saying by local media.

Mr Paylan, a politician of ethnic Armenian descent, added: “Nobody is safe against this judicial cruelty in Turkey. I am seriously worried about arbitrary judicial decisions and trumped-up charges.”

The prosecution of Mr Kavala, who has used his inherited wealth to finance numerous political and cultural projects, has underscored the country’s political and cultural divides, pitting Turkey’s older secular elites against the newly dominant power of Mr Erdogan and his allies.

Mr Erdogan has in the past called Mr Kavala the “local collaborator” of the “Hungarian Jew” George Soros, in reference to the Hungarian-born financier and philanthropist.

“The Gezi incidents directly cost Turkey $1.4bn while its indirect cost was hundreds of billions of dollars,” Mr Erdogan said in a speech on Wednesday. “Whoever defines Gezi incidents as an innocent environmental movement is either ignorant or an enemy of this country and nation.”

The prosecutor has vowed to challenge the judiciary decision to acquit Mr Kavala and the others on the 2013 protest charges.

Erdogan says he handed back 'tough guy' letter to Trump as two leaders at odds over Kurds

Allegations that Mr Kavala had a role in the 2016 coup attempt are odd in light of the fact that it was Mr Erdogan and the Justice and Development Party that originally allowed Mr Gulen’s cult-like spiritual movement into government and security institutions, as an ally against Turkey’s military-dominated old order.

Secular liberals like Mr Kavala were hostile to the Gulenists and were targeted by the movement’s supporters in the interior ministry and judiciary. Ironically, Mr Kavala, the scion of a wealthy Turkish family, was considered a supporter of Mr Erdogan when the Islamist-rooted leader and his allies took on the power and privileges of the military.

Amnesty International called the continued detention of Mr Kavala “cynical and outrageous”.