Six people have been arrested in Turkey for allegedly insulting President Recep Tayyip Erdogan, as the polls opened and voting began in major national elections.

The state-run Anadolu Agency said the six were detained late on Saturday, days after videos posted on social media reportedly showed them shouting expletives against Mr Erdogan.

The news agency said they were later charged with "insulting state elders" and that police were searching for other suspects.

Insulting the president is a crime punishable by up to four years in prison. Mr Erdogan has filed close to 2,000 lawsuits against people, including school children, for insulting him.

As a goodwill gesture, he dropped the cases following a failed military coup in 2016. But many more cases have been filed since then.

Erdogan tells a girl in military uniform that she would be honoured if killed while fighting

Sunday’s election poses the biggest ballot box challenge to Mr Erdogan and his Islamist-rooted AK Party since they swept to power more than a decade and a half ago.

The elections will also usher in a powerful new executive presidency long sought by Mr Erdogan and backed by a small majority of Turks in a 2017 referendum. Critics say it will further erode democracy in the NATO member state and entrench one-man rule.

Mr Erdogan, the most popular but also divisive leader in modern Turkish history, moved the elections forward from November 2019, arguing the new powers would better enable him to tackle the nation's mounting economic problems - the lira has lost 20 per cent against the dollar this year - and deal with Kurdish rebels in southeast Turkey and in neighbouring Iraq and Syria.

But he reckoned without Muharrem Ince, the presidential candidate of the secularist Republican People's Party (CHP), whose feisty performance at campaign rallies has galvanized Turkey's long-demoralised and divided opposition.

Addressing a rally in Istanbul on Saturday attended by hundreds of thousands of people, Mr Ince promised to reverse what he and opposition parties see as a swing towards authoritarian rule under Mr Erdogan in the country of 81 million people.

"If Erdogan wins, your phones will continue to be listened to ... Fear will continue to reign ... If Ince wins, the courts will be independent," said Mr Ince, adding he would lift Turkey's state of emergency within 48 hours of being elected.

Turkey has been under emergency rule - which restricts some personal freedoms and allows the government to bypass parliament with emergency decrees - for nearly two years following an abortive military coup in July 2016.

Mr Erdogan blamed the coup on his former ally, U.S.-based Muslim cleric Fethullah Gulen, and has waged a sweeping crackdown on the preacher's followers in Turkey. The United Nations say some 160,000 people have been detained and nearly as many more, including teachers, judges and soldiers, sacked.

In pictures: Turkey coup attempt Show all 17 1 /17 In pictures: Turkey coup attempt In pictures: Turkey coup attempt Turkish President Erdogan attends the funeral service for victims of the thwarted coup in Istanbul at Fatih mosque on July 17, 2016 in Istanbul, Turkey Burak Kara/Getty Images In pictures: Turkey coup attempt Soldiers involved in the coup attempt surrender on Bosphorus bridge with their hands raised in Istanbul on 16 July, 2016 Gokhan Tan/Getty In pictures: Turkey coup attempt A civilian beats a soldier after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 REUTERS/Murad Sezer In pictures: Turkey coup attempt Surrendered Turkish soldiers who were involved in the coup are beaten by a civilian Reuters In pictures: Turkey coup attempt Soliders involved in the coup attempt surrender on Bosphorus bridge Getty In pictures: Turkey coup attempt Supporters of Turkish President Recep Tayyip Erdogan wave flags as they capture a Turkish Army vehicle Getty In pictures: Turkey coup attempt People pose near a tank after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 Reuters In pictures: Turkey coup attempt Turkish soldiers block Istanbul's Bosphorus Brigde Getty In pictures: Turkey coup attempt A Turkish military stands guard near the Taksim Square in Istanbul Reuters In pictures: Turkey coup attempt Pierre Crom/Twitter In pictures: Turkey coup attempt Turkish soldiers secure the area as supporters of Recep Tayyip Erdogan protest in Istanbul's Taksim square AP In pictures: Turkey coup attempt People demonstrate in front of the Republic Monument at the Taksim Square in Istanbul Murad Sezer/Reuters In pictures: Turkey coup attempt Turkish soldiers detain police officers during a security shutdown of the Bosphorus Bridge Reuters In pictures: Turkey coup attempt Turkish Army armoured personnel carriers in the main streets of Istanbul Getty In pictures: Turkey coup attempt Chaos reigned in Istanbul as tanks drove through the streets EPA/TOLGA BOZOGLU In pictures: Turkey coup attempt Turkish President Tayyip Erdogan speaks to media in the resort town of Marmaris Reuters In pictures: Turkey coup attempt Supporters of President Erdogan celebrate in Ankara following the suppression of the attempted coup Reuters

The president's critics, including the European Union which Turkey still nominally aspires to join, say Mr Erdogan has used the crackdown to stifle dissent. Few newspapers or other media openly criticise the government and he has received far more election coverage than other presidential candidates.

Mr Erdogan, who defends his tough measures as essential for national security, told his supporters at rallies on Saturday that if re-elected he would press ahead with more of the big infrastructure projects that have helped turn Turkey into one of the world's fastest-growing economies during his time in office.

Polls show Mr Erdogan falling short of a first-round victory in the presidential race but he would be expected to win a run-off on July 8, while his AK Party could lose its parliamentary majority, possibly heralding increased tensions between president and parliament.

Other presidential candidates include Selahattin Demirtas, leader of the pro-Kurdish Peoples' Democratic Party (HDP), who is currently in jail on terrorism-related charges that he denies.

In a final appeal for votes in a video clip from his high security prison, Mr Demirtas said: "If the HDP fails to get into parliament, all Turkey will lose. Backing the HDP means supporting democracy."