John Bacon

USA TODAY

Turkish President Recep Tayyip Erdogan joined leaders of Turkey’s three main political parties and a massive throng of countrymen in Istanbul for a historic pro-democracy rally Sunday to protest the military's failed coup last month.

Erdogan called for the rally that drew a sea of Turkish flags to Yenikapi square.

“Our presence today upsets our enemies, just like it did on the morning of July 16," Erdogan told the crowd, according a translation by Turkey's state-run Anadolu news agency. "On that night there were people who risked their lives to stop the coup and they filled the streets. History will remember names of our martyrs … in golden letters.”

Opposition leader Kemal Kilicdaroglu, in a rare appearance at a rally with Erdogan, said the failed coup opened a "new door of compromise" and said politics must be kept out of mosques, courthouses and barracks.

Police estimated 5 million people turned out for Sunday's rally, Anadolu reported. The Qatar-based Al Jazeera agency estimated the crowd at more than 1 million.

The event marked the end of weeks of rallies across the nation since the ill-fated coup, which left hundreds dead, more than 2,000 wounded and many thousands more arrested. An estimated 70,000 people have been suspended from their jobs.

Turkish president tightens grip on military

Turkey's government has blamed the coup on followers of Turkish cleric Fethullah Gulen, who has lived in self-imposed exile in Pennsylvania since 1999. Erdogan has demanded the U.S. extradite Gulen, and the case has created tension between the two nations, key partners in the war against the Islamic State.

Gulen is accused of leading a long-running campaign to overthrow the government through the infiltration of Turkish institutions, particularly the military, police and judiciary. Turkey sent its first extradition request July 19, days after the failed coup.

Gulen denies any involvement in the coup, and Secretary of State John Kerry has said Turkey must provide evidence of Gulen’s involvement for a judge to consider any extradition request. An angry Erdogan has accused the West of backing terrorism and coups.

Erdogan has moved to consolidate power since the coup attempt, shutting down scores of media outlets, placing the military more firmly under the control of the civilian government and firing more than 3,000 members of the military.