Demirtas, the former co-leader of the Peoples' Democratic Party (HDP) and still by far its most prominent figure, has been held since November 2016 on charges of links to outlawed Kurdish militants.
But the party chose him as its candidate to challenge Erdogan in the June 24 polls and, undeterred, Demirtas called on every member of the party to campaign in his name.
Divided Kurds face losses in Iraq's election
"I trust you because you are my voice and my breath," Demirtas wrote last week.
The ex-HDP leader was detained during the crackdown launched after the July 2016 failed coup which critics say went well beyond targeting just the plotters.
Demirtas, 45, is accused of being a member of the outlawed Kurdistan Workers' Party (PKK) and making propaganda for the group blacklisted as a terrorist organisation by Ankara and its Western allies. He risks up to 142 years in jail.
The former human rights lawyer won almost 10% of the vote in the presidential elections of 2014, establishing himself as a serious rival to Erdogan.
The HDP then became the first pro-Kurdish party to enter parliament in June 2015 elections, maintaining its status as the second largest opposition party in a re-run of the polls in November that year.
"The fact that (Demirtas) is in prison is illegal and unfair. We wanted to show that we do not accept this injustice," Demirtas' campaign co-ordinator and deputy co-leader of the party, Saruhan Oluc, told AFP.
From his prison cell in the northwest province of Edirne which he shares with another HDP MP, Demirtas tweets almost daily through his lawyers, alternating between political messages, comments on the news and strokes of humour.
"From the survey I undertook in the prison cell, I won 100% each time. Just kidding :). There was one time when I was angry at myself and I obtained 50% of the vote," he quipped.
Meanwhile, the HDP's current co-leaders Pervin Buldan and Sezai Temelli are campaigning across the country for the simultaneous presidential and parliamentary elections.
Iraqis voting in first election since Islamic State
"It's difficult (to campaign this way), but it does not occur to us that we will fail," Temelli told AFP on board his campaign bus in Ankara.
Several HDP officials have said that on the ground, their stands and rallies are often harassed by public officials including police.
"All the institutions... are working now hand-in-hand for the HDP to stay under the threshold (of 10% needed to enter parliament) and not letting the party campaign," Temelli said.
The HDP, which Erdogan accuses of having close links to the PKK, is given very little media coverage in mainstream Turkish media.
According to Transparency International Turkey, state broadcaster TRT only gave three seconds of airtime to Demirtas in its main television news programming in May compared to 105 minutes for Erdogan.
As with the other candidates, the Supreme Election Board (YSK) nonetheless has allowed Demirtas to record a campaign message for TRT. The HDP has asked for Demirtas to be allowed to film outside prison.
The HDP has also organised a "press conference" on social media where users will be able to ask their questions which the lawyers will put to Demirtas and he will respond on Friday.
Murat Gezici, the head of the polling company Gezici, said Demirtas' incarceration "can break the motivation of HDP voters", who assume that the battle is lost in advance.
According to Gezici polls, Demirtas will win eight to nine percent of the vote in the presidential election, and HDP 9.7% in the parliamentary poll.
But Ozer Sencar, chairman of the Metropoll pollster, said his polls indicate Demirtas could win 11.4% of the vote and the HDP 11%.
"The fact that he is in prison is not a negative thing," Sencar said.
"Demirtas is the best candidate the HDP could put forward: young, intelligent, with a good sense of humour, liked by Kurds and for whom Turks, especially leftists, have sympathy."
Durust, an HDP supporter at an Ankara event, said the party's struggle was far from over. "We are at a pivotal moment, it's either the HDP or our end."
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ