Opposition leaders and vast crowds of ordinary Turks on Sunday rallied behind President Recep Tayyip Erdogan in a huge show of unity against the plotters of last month's failed coup. The massive pro-democracy demonstration transformed the city's Yenikapi Square into a heaving sea of red and white Turkish flags with many taking part wearing headbands emblazoned with Erdogan's name. One banner declared "the victory is democracy's, the square is the people's". Erdogan was joined at the grand "Democracy and Martyrs" rally by the main opposition Republican People's Party (CHP) leader, Kemal Kilicdaroglu, and Nationalist Movement Party (MHP) leader Devlet Bahceli. Pro-government media said at least three million attended the gathering which was held under tight security with 15,000 police on duty. A senior government official, who did not wish to be named, said there was an estimated five million people in the square and vicinity. In a final speech, the president said that the movement run by US-based preacher Fethullah Gulen and blamed by Ankara for the July 15 coup attempt would "pay a price for what they have done". And he said that political parties would respect the will of the people if they wanted the return of the death penalty. "If the nation makes such a decision (in support of the death penalty), I believe political parties will abide by this decision," Erdogan said. "It is the Turkish parliament that will decide on this (the death penalty) given the sovereignty rests with the nation... I declare it in advance, I will approve the decision made by the parliament." Similar remarks by Erdogan have previously caused concern among European Union member states after Turkey abolished the death penalty in 2004 as part of its efforts to join the 28-nation bloc. - 'Path of solidarity' - But Erdogan dismissed critics saying that capital punishment existed in the United States, Japan and China. In a surprise speech, the chief of staff Hulusi Akar -- briefly kidnapped during the coup -- was hailed a a hero by the crowd but then interrupted by others calling for the death penalty. Followers of Erdogan's Justice and Development Party (AKP) have taken to the streets every night since the attempted putsch that claimed at least 273 lives including 34 coup plotters. The rallies were not limited to Istanbul and the capital Ankara. Thousands rallied in the popular tourist spots of Izmir in the west, Antalya in the south as well as Diyarbakir in the restive south-east. During his speech, Erdogan vowed that the "path of solidarity" created in the aftermath of the failed putsch would continue. Although the pro-Kurdish Peoples' Democratic Party (HDP) was not invited, Erdogan, Kilicdaroglu and Bahceli presented a united front against the coup plotters and praised the Turkish people. Kilicdaroglu, who initially said he would not take party in the rally, described how significant the event was for Turkey's political and democratic history. But he warned that all politicians needed "to learn a lesson from these calamitous events", adding: "Politicians should be left out of mosques, barracks, courthouses." In what appeared to be remarks aimed at Erdogan who wants to create an executive presidential system, Kilicdaroglu said Turkey had to strengthen its parliamentary system. He also praised the "independent media" for their coverage of the coup without whom "maybe no one would have got out onto the streets". MHP leader Bahceli praised the Turkish people for going up against bullets "as if they were walking into a rose garden" and for protecting the country's honour. He added that a new era was beginning in Turkish politics after the Yenikapi gathering. - 'Sweeping crackdown' - Among those in the crowd were supporters from across the political spectrum. Wearing a hat covered in the Turkish flag on top of her headscarf, Aynur said she hoped that political parties would remain united after the rally. "All the political parties are united, a picture we have longed to see. God willing, this unity will last forever," said the AKP supporter who has also voted for the opposition CHP in the past. Osman Kor, aged 45, said he was attending because Kilicdaroglu was attending. "I am a CHP voter and an advocate of left-wing principles. Our leader is here, so we are," he said. Turkey has accused the reclusive Gulen of masterminding the coup attempt, which was led by a rogue faction in the military. From his base in Pennsylvania, Gulen denies the charges. Erdogan retaliated after the coup with a sweeping crackdown on alleged coup plotters. Over 60,000 people from the military, judiciary, civil service and education have been dismissed, detained or put under investigation for suspected links to the Gulen movement.