President Recep Tayyip Erdogan criticised Turkey's main opposition party over its protest march launched after a party deputy got 25 years in prison for espionage.

Republican People's Party (CHP) leader Kemal Kilicdaroglu began the march after the jailing of CHP politician Enis Berberoglu, who was jailed for leaking information on the transport of arms to Syria.

Speaking at his Justice and Development (AK) Party's provincial meeting in the capital Ankara, Erdogan said: "If you are launching a march for terrorists and for their supporters, something which you have never thought about doing against terrorist groups, you can convince no one that your aim is justice."

Erdogan accused the party of acting with "terrorist" groups and forces that incite such groups against Turkey.

"This situation, which anyone who in their right mind can see clearly, is part of traps set up in Syria, Iraq, the Gulf, and Europe against our country," he added.

Kilicdaroglu intends to complete the 450km walk from Ankara to Maltepe prison in Istanbul, where Berberoglu is being held, in 24 days.

Marching without party insignia and simply a sign with the word "justice" in Turkish, he has been followed by thousands every day and plans to end the march on July 9 with a mass rally outside the prison.

Kilicdaroglu is being accompanied by CHP deputies and supporters, as well as family members.

Berberoglu was convicted of revealing state secrets by passing images to Cumhuriyet daily of Turkish intelligence trucks en route to Syria in January 2014.

He is the first CHP deputy to be imprisoned in recent years. Around a dozen legislators from the Peoples' Democratic Party (HDP) are currently jailed, most awaiting trial over alleged links to the PKK.

In May 2016, parliament voted to strip legislators facing trial of their parliamentary immunity.