Erdoğan was born in the Kasımpaşa neighborhood in Istanbul, to which his family had moved from Rize Province.

Brought up in an observer Muslim family, Erdoğan graduated from Kasımpaşa Piyale primary school in 1965, and İmam Hatip school, a religious vocational high school, in 1973. He received his high school diploma from Eyüp High School.

Erdoğan engaged in politics by joining the National Turkish Student Union, an anti-communist action group. In 1974, he wrote, directed and played the lead role in the play Maskomya, which presented Freemasonry, Communism and Judaism as evil. In 1976, he became the head of the Beyoğlu youth branch of the Islamist National Salvation Party (MSP). and was later promoted to chair of the Istanbul youth branch of the party.

Erdoğan married Emine Gülbaran (born 1955, Siirt) on 4 July 1978.

After the 1980 military coup, Erdoğan followed most of Necmettin Erbakan's followers into the Islamist Welfare Party. He became the party's Beyoğlu district chair in 1984, and in 1985 he became the chair of the Istanbul city branch.

In the local elections of 27 March 1994, Erdoğan was elected Mayor of Istanbul, with a plurality (25.19%) of the popular vote. He was pragmatic in office, tackling many chronic problems in Istanbul including water shortage, pollution and traffic chaos.

In December 1997 in Siirt, Erdoğan recited a poem from a work written by Ziya Gökalp, a pan-Turkish activist of the early 20th century. His recitation included verses translated as "The mosques are our barracks, the domes our helmets, the minarets our bayonets and the faithful our soldiers...." which are not in the original version of the poem. Erdoğan said the poem had been approved by the education ministry to be published in textbooks. Under article 312/2 of the Turkish penal code his recitation was regarded as an incitement to violence and religious or racial hatred. He was given a ten-month prison sentence of which he served four months, from 24 March 1999 to 27 July 1999. Due to his conviction, Erdoğan was forced to give up his mayoral position. The conviction also stipulated a political ban, which prevented him from participating in parliamentary elections.

The elections of 2002 were the first elections in which Erdoğan participated as a party leader. All parties previously elected to parliament failed to win enough votes to re-enter the parliament. The AKP won 34.3% of the national vote and formed the new government. Turkish stocks rose more than 7% on Monday morning. Politicians of the previous generation, such as Ecevit, Bahceli, Yılmaz and Çiller, resigned. The second largest party, the CHP, received 19.4% of the votes. The AKP won a landslide victory in the parliament, taking nearly two-thirds of the seats. Erdoğan could not become Prime Minister as he was still banned from politics by the judiciary for his speech in Siirt. Gül became the Prime Minister instead.

In December 2002, the Supreme Election Board canceled the general election results from Siirt due to voting irregularities and scheduled a new election for 9 February 2003. By this time, party leader Erdoğan was able to run for parliament due to a legal change made possible by the opposition Republican People's Party. The AKP duly listed Erdoğan as a candidate for the rescheduled election, which he won, becoming Prime Minister after Gül handed over the post.

Erdoğan visited Israel on 1 May 2005, a gesture unusual for a leader of a Muslim majority country. During his trip, Erdoğan visited the Yad Vashem, Israel's official memorial to the victims of the Holocaust.

On 3 October 2005 negotiations began for Turkey's accession to the European Union.

In April 2006, Erdoğan unveiled a social security reform package demanded by the International Monetary Fund under a loan deal. The move, which Erdoğan called one of the most radical reforms ever, was passed with fierce opposition. Turkey's three social security bodies were united under one roof, bringing equal health services and retirement benefits for members of all three bodies.

On 14 April 2007, an estimated 300,000 people marched in Ankara to protest against the possible candidacy of Erdoğan in the 2007 presidential election, afraid that if elected as President, he would alter the secular nature of the Turkish state.

Erdoğan announced on 24 April 2007 that the party had nominated Abdullah Gül as the AKP candidate in the presidential election.

The stage of the elections of 2007 was set for a fight for legitimacy in the eyes of voters between his government and the CHP. Erdoğan used the event that took place during the ill-fated Presidential elections a few months earlier as a part of the general election campaign of his party. On 22 July 2007, the AKP won an important victory over the opposition, garnering 46.7% of the popular vote. 22 July elections marked only the second time in the Republic of Turkey's history whereby an incumbent governing party won an election by increasing its share of popular support.

The relationship between Israel and Turkey worsened at the 2009 World Economic Forum conference over Israel's actions during the Gaza War. Erdoğan was interrupted by the moderator while he was responding to Peres, and left the panel, accusing the moderator of giving Peres more time than all the other panelists combined. Tensions increased further following the Gaza flotilla raid in May 2010. Erdoğan strongly condemned the raid, describing it as "state terrorism", and demanded an Israeli apology. In February 2013, Erdoğan called Zionism a "crime against humanity", comparing it to Islamophobia, antisemitism, and fascism.

On 12 May 2010, Turkey and Russia signed 17 agreements to enhance cooperation in energy and other fields, including pacts to build Turkey's first nuclear power plant and further plans for an oil pipeline from the Black Sea to the Mediterranean Sea. The leaders of both countries also signed an agreement on visa-free travel, enabling tourists to get into the country for free and stay there for up to 30 days.

In the June 2011 elections, Erdoğan's governing party won 327 seats (49.83% of the popular vote) making Erdoğan the only prime minister in Turkey's history to win three consecutive general elections, each time receiving more votes than the previous election. The second party, the Republican People's Party (CHP), received 135 seats (25.94%), the nationalist MHP received 53 seats (13.01%), and the Independents received 35 seats (6.58%).

Erdoğan visited Egypt on 12 September 2011, soon after Turkey had ejected Israeli ambassadors, cutting off all diplomatic relations with Israel because Israel refused to apologize for the Gaza flotilla raid which killed eight Turkish and one Turco-American. This was the first visit to Egypt by a Prime Minister of Turkey after the Egyptian Revolution of 2011.

On 23 November 2011, during a televised meeting of his party in Ankara, he apologised on behalf of the state for the Dersim massacre, where many Alevis and Zazas were killed.

A file containing five audio recordings of conversations between Erdoğan and his son from a 26-hour period beginning 17 December 2013, in which he appeared to be instructing his son to conceal very large amounts of money, was posted to YouTube and widely discussed on social media.

In December 2013, Turkish police detained more than 50 people and arrested 16 others, including the general manager of Halkbank and the sons of three government ministers, on charges of corruption. Erdoğan reshuffled his Cabinet on 25 December, replacing 10 ministers hours after three ministers, whose sons were detained in relation to the probe, resigned.

On 26 February 2014, Erdoğan acknowledged that his telephone had been tapped, but denied that the conversation was real, instead calling it an "immoral montage" that had been "dubbed" by combining other conversations. An analysis by Joshua Marpet of the United States, published by McClatchy, concluded that the recordings were "probably real", and if not, the fabrication was done with a sophistication he had not previously seen.

On 20 March, Erdoğan made a speech promising to "rip out the roots" of the Twitter service. Hours later the telecommunications regulator BTK blocked DNS service to the site, citing four court orders the Turkish government had made requiring them to remove content to preserve privacy that had not been heeded. Sources covering the story attributed this to the use of Twitter to share links to the Erdoğan recordings on YouTube. Erdoğan also threatened to ban Facebook.

However, the block of Twitter proved ineffective, with traffic increasing a record 138%, and #TwitterisblockedinTurkey becoming the top trending term worldwide. To circumvent the block, Google suggested Turks use Google Public DNS at 8.8.8.8 and 8.8.4.4, numbers which were soon graffitied in dozens of locations around Istanbul. President Abdullah Gül criticized the Twitter ban. Two months later, on 3 June, Turkey's telecommunications watchdog ordered the ban to be lifted, after a ruling by the Constitutional Court.

On 1 July 2014, Erdoğan was named the AKP's presidential candidate in the Turkish presidential election. His candidacy was announced by the Deputy President of the AKP, Mehmet Ali Şahin.

Erdoğan was elected as the President of Turkey in the first round of the election with 51.79% of the vote, obviating the need for a run-off by winning over 50%. The joint candidate of the CHP, MHP and 13 other opposition parties, former Organisation of Islamic Co-operation general secretary Ekmeleddin İhsanoğlu won 38.44% of the vote. The pro-Kurdish HDP candidate Selahattin Demirtaş won 9.76%.

Erdoğan took the oath of office on 28 August 2014 and became the 12th president of Turkey. He administered the new Prime Minister Ahmet Davutoğlu's oath on 29 August. When asked about his lower-than-expected 51.79% share of the vote, he allegedly responded, "there were even those who did not like the Prophet. I, however, won 52%."

Erdoğan also tightened controls over the internet, signing into law a bill which allows the government to block websites without prior court order on 12 September 2014. In November 2016, the Turkish government blocked access to social media in all of Turkey as well as bought to completely block internet access for the citizens in the Southeast of the country.

On 15 July 2016, a coup d'état was attempted by the military, with aims to remove Erdoğan from government. By the next day, Erdoğan's government managed to reassert effective control in the country. Reportedly, no government official was arrested or harmed, which among other factors raised the suspicion of a false flag event staged by the government itself.

On 20 July 2016, President Erdoğan declared the state of emergency, citing the coup d'état attempt as justification. It was first scheduled to last three months. The Turkish parliament approved this measure.The state of emergency was later extended for another three months, amidst the ongoing 2016 Turkish purges including comprehensive purges of independent media and detention of tens of thousands of Turkish citizens politically opposed to Erdoğan. More than 50,000 people have been arrested and over 160,000 fired from their jobs by March 2018.

With the new Turkish constitution which got approved in the constitutional referendum on 16 April 2017, Turkey became a country with a Presidential system, the office of prime minister got abolished and the age of candidacy to the parliament was lowered from 25 to 18.

On Sunday, 16 April 2017, a constitutional referendum was held, where the voters in Turkey (and Turkish citizens abroad) voted on a set of 18 proposed amendments to the Constitution of Turkey. The amendments include the replacement of the existing parliamentary system with a presidential system. The post of Prime Minister would be abolished, and the presidency would become an executive post vested with broad executive powers. Parliament would be increased from 550 seats to 600 seats. The referendum also called for changes to the Supreme Board of Judges and Prosecutors.

On 29 April 2017 Erdoğan's administration began an internal Internet block of all the Wikipedia online encyclopaedia site via Turkey's domestic Internet filtering system. This blocking action took place after the government had first made a request for Wikipedia to remove what it referred to as "offensive content". In response, Wikipedia co-founder Jimmy Wales replied via a post on Twitterating, "Access to information is a fundamental human right."

On 14 June 2018, in a video that was leaked to the public, President Erdogan is caught calling his party members to resort to electoral fraud, by "marking" the votes of an opposition party, HDP, in a bid to consolidate a better position for his own party at the 2018 June elections in Turkey.

On 8 July 2018, Erdogan sacked 18,000 officials for alleged ties to US based cleric Fethullah Gülen, shortly before renewing his term as an executive president. Of those removed, 9000 were police officers with 5000 from the armed forces with the addition of hundreds of academies.