Gül became Prime Minister after the AKP won a landslide victory in the 2002 general election while Erdoğan was still banned from office. His government removed Erdoğan's political ban by March 2003, after which Erdoğan became an MP for Siirt in a by-election and took over as Prime Minister. Gül subsequently served as Minister of Foreign Affairs and Deputy Prime Minister until 2007. His subsequent bid for the Presidency drew strong and highly vocal opposition from ardent supporters of secularism in Turkey and was initially blocked by the Constitutional Court due to concerns over his Islamist political background. He was eventually elected Turkey's first President with a background in Islamic politics after the 2007 snap general election.