Some 3.5 million to five million Turks poured into the Yenikapi Square in Istanbul waving Turkish flags, joining President Recep Tayyip Erdogan and leaders of the country's main political parties.
In his speech, Erdogan said in the face of solidarity against coup plotters, "the country's enemies have now realized that their job is difficult."
"It is the proclamation and evidence that Turkey will reach its 2023 targets," he stressed, referring to goals set for the occasion of the republic's 100th anniversary that includes to be among the world's top 10 economies.
Speaking of the possibility of restoring the death penalty, the president vowed once again to approve the decision to be taken by the parliament.
The issue of a reinstated capital punishment was raised in the wake of the failed bid on July 15 but has sparked concern in the West.
Binali Yildirim, leader of the ruling Justice and Development Party and the prime minister, voiced his gratitude to the leaders of the opposition parties for being present at the rally and said his party would do its best to preserve the unity.
The rally under the theme of "Democracy and Martyrs" was called for by the president, but the pro-Kurdish People's Democratic Party that is also represented in parliament was not invited for its link to the outlawed Kurdistan Workers' Party, which has been seeking autonomy in southeastern Turkey.
The bid to overthrow the government by a faction within the military was crushed within hours, but left 240 people dead and more than 2,000 others injured.
The speech by Chief of General Staff Gen. Hulusi Akar was frequently cut short by cheers and applause from the crowd.