Turkish media reports say a court in Istanbul has sentenced a prominent journalist to more than five years in prison hours after he escaped an attack by a gunman.

The court on Friday found Can Dundar, editor in chief of Cumhuriyet newspaper, guilty of revealing state secrets for publishing reports on alleged government arms smuggling to Syrian rebels.

The paper's Ankara representative, Erdem Gul, was also convicted.

Earlier Friday, a gunman shouting "traitor" fired two shots at Dundar outside the courthouse. Dundar was not harmed, but another journalist was slightly injured in the leg.

The journalists are expected to appeal the verdict.