Istanbul (AFP) - Two Turkish journalists went on trial in Istanbul Friday facing possible life terms on controversial espionage charges, with the court immediately barring the public from a case seen as a test of press freedom under President Recep Tayyip Erdogan.

Can Dundar, editor-in-chief of leading opposition daily Cumhuriyet, and Erdem Gul, his Ankara bureau chief, are charged with espionage and revealing state secrets over a story accusing the government of seeking to illicitly deliver arms to rebels in Syria.

Within two hours of the start of the proceedings the judge ordered the trial to be held behind closed doors, granting a request by the prosecution which cited "national security" concerns.

The decision was met with cries of dismay inside the courtroom. Several opposition politicians refused to leave, prompting the judge to adjourn the trial until April 1.

"To judge journalists in camera is further proof that Turkish authorities and President Erdogan have something to hide," said Christophe Deloire, secretary general of press freedom campaign group Reporters Without Borders, who attended the proceedings.

"The rule of law in Turkey is in dire straits."

Arrested in November, Dundar and Gul spent three months in pre-trial detention before being released in February on the orders of the Constitutional Court, which ruled their right to free speech had been violated.

The prosecution has asked they be sentenced each to two life terms and 30 additional years.

Around 200 people, including a number of journalists and opposition lawmakers, greeted the reporters as heroes on their arrival at the court Friday, chanting: "You cannot silence press freedom".

In a sign of the intense interest in the case, several EU diplomats including the German ambassador attended the start of the trial.

"We are here to defend journalism," Dundar, 54, told reporters. Gul said he wanted to show that journalism "is not a crime".

- 'Heavy price' -

Cumhuriyet's report on a shipment of arms being intercepted at the Syrian border in January 2014 sparked a furore when it was published in May, fuelling speculation about Turkey's role in the Syrian conflict and its alleged ties to Islamist groups in the country.

Story continues

Erdogan reacted furiously to the allegations, personally warning Dundar he would "pay a heavy price". The court on Friday accepted the president and Turkey's intelligence agency as civil plaintiffs in the case.

Dundar and Gul won a first victory on February 26, when the Constitutional Court -- one of the last institutions not under the full control of Erdogan's Justice and Development Party -- ruled they should be freed.

A vexed Erdogan declared he had "no respect" for the court's decision.

Dundar said he and Gul had found themselves "caught between two palaces: the palace of justice and the palace of illegality," referring to the lavish, 1,150-room presidential complex in Ankara which Erdogan had built at a cost of $615 million.

"We will see which of the two... emerges victorious," he said.

The prosecution of the journalists sparked outrage among opposition and rights groups in Turkey as well as in the West, where some have seen it as evidence of Erdogan's determination to silence his opponents.

In an open letter to Prime Minister Ahmet Davutoglu on the eve of the trial, more than 100 leading authors, including Canada's Margaret Atwood and Peru's Maria Vargas Llosa, called for the charges to be dropped.

- Newspaper seized -

Reporters Without Borders ranked Turkey 149th out of 180 countries for press freedom in 2015 over the widening clampdown on critics of the president and the state's bloody war with militants from the outlawed Kurdistan Workers' Party.

Turkey's government -- which is scrambling to respond to a series of suicide attacks by Islamic State jihadists and Kurdish rebels that have killed over 200 people since July -- has accused academics, journalists and activists who question its policies of "terrorist propaganda".

Almost 2,000 people have been prosecuted for "insulting" Erdogan since the former premier became president in August 2014, Turkey's justice minister said earlier this month.

In one of the most dramatic recent moves against the press, the authorities seized the opposition Zaman newspaper earlier this month and placed it under state supervision.

A day after the change of management, Zaman, which is allied to Erdogan's arch-enemy, exiled preacher Fethullah Gulen, abruptly changed its editorial policy, adopting a pro-government line.