More than a million people have attended a pro-democracy rally held in Istanbul in response to Turkey's failed coup attempt last month.

The massive rally on Sunday united the country's president, the prime minister and two opposition party leaders around a single issue for the first time in years.

"The world is looking at you now," President Recep Tayyip Erdogan told the rally as he began his speech. "You should be proud of yourselves. Each and everyone of you fought for freedom and democracy. All of you are heroes."

Erdogan said that on the night of the coup, the Turkish people had proved that "we are mighty enough to foil any coup", condemning the group behind the plot to topple his government as a "terrorist organisation".

READ MORE: Turkish political parties unite against coup attempt

The president also said that, had the coup attempt succeeded, "we would have lost our homeland, and offered it to our enemy in a silver platter".

Al Jazeera's Ayse Karabat, reporting from Istanbul, described the event as "the biggest, most crowded, political meeting in Turkish political history".

As part of its anti-coup campaign, the government has been encouraging nightly rallies throughout the country, culminating in Sunday's grand finale.

The "Democracy and Martyrs' Rally" was designed to represent the unity of the country, and Erdogan had urged attendees to bring only the Turkish flag, instead of party banners.

About 13,000 people, in addition to police officers, were involved in running the event. Helicopters, ambulances and more than 700 medical personnel were also on duty.

Similar rallies were held simultaneously across the country, according to officials from the ruling Justice and Development Party (AKP).

Death penalty backed

Erdogan, Prime Minister Binali Yildirim, who is also the leader of the AKP, as well as the main opposition Republican People’s Party leader Kemal Kilicdaroglu and Nationalist Movement Party leader Devlet Bahceli were present at the rally.

Kilicdaroglu and Bahceli addressed the rally before handing the stage to the prime minister and the president.

In his speech, Erdogan said that he would support the re-introduction of the death penalty should parliament approve it, saying that countries such as the United States and China also have capital punishment.

Yildirim praised those "who fought bravely and stood in defiance" of the coup attempt.

Opposition leader Kilicdaroglu said the failed coup had opened a "new door of compromise" in politics, adding that politics must now be kept out of the mosques, courts and barracks.

"There is a new Turkey after July 15," Kilicdaroglu said.

READ MORE: How could Turkey's failed coup affect the Kurdish peace process?

The pro-Kurdish People's Democracy Party's (HDP) co-leaders, Selahattin Demirtas and Figen Yuksekdag were not invited. The HDP opposed the coup, but was excluded from the rally because of its alleged support for the outlawed Kurdistan Workers' Party (PKK).

Galip Dalay, columnist and Turkey analyst, told Al Jazeera that including the HDP would have "completed the picture". He said, though, that the event was significant as it showed "unity across [the] political spectrum."

Turkey, the US and the European Union call the PKK, an armed group that has been fighting for Kurdish autonomy since 1984, a "terrorist organisation".

Erdogan has previously called for HDP members to be prosecuted, accusing the party of being the PKK's political wing.

The HDP is the third-biggest party in parliament. It denies having direct links with the PKK and promotes a negotiated end to the Kurdish conflict, which has claimed hundreds of lives since a peace process, once led by Erdogan and his governing party, collapsed in 2015.

'One nation, one heart'

Before and during the rally, the hashtags #birliktegucluyuz (Together we are strong) and #TekmilletTekyurek (One nation, one heart) were trending on Twitter, with thousands of people revelling in the solidarity on show between the political parties.

Today,Turkish people from all background and political affiliations are on the streets to defend democracy! #TurkeyUnited #TekMilletTekYürek — Bekir Gür (@bekirgur) August 7, 2016

The failed coup, led by a faction of the Turkish military, killed more than 270 people and posed the gravest threat yet to Erdogan's 13 years in power.

Factions of the security forces loyal to Erdogan, with the help of thousands of Turkish citizens who took to the streets to confront the troops, quickly put down the attempt.

US-based preacher and businessman Fethullah Gulen, a former Erdogan ally, has been blamed for the coup attempt. He has denied any involvement and condemned it.

Since the events of July 15, more than 70,000 people in the military, judiciary, civil service and education sector have been arrested or suspended for alleged links to Gulen's movement.