Mohammed Morsi was declared President of Egypt on 24 June 2012, becoming the first democratically elected president in that nation's history. Morsi, a professor of engineering from Zagazig University, was elected in a run-off election as the candidate from the Muslim Brotherhood's Freedom and Justice Party. He emerged as that party's candidate after others in his party were disqualified from running-- in the first presidential election since the removal of Hosni Mubarak in February of 2011. Morsi won 51.7% of the vote over Ahmed Shafiq, a general who had been Mubarak's last prime minister. Morsi earned his engineering degrees at Cairo University in the late 1970s, and around the same time, he joined the Muslim Brotherhood. He spent the early 1980s in the United States, earning a doctorate from the University of Southern California in 1982, then working as a professor at California State University in Northridge from 1982 until 1985. After 1985 he taught at Zagazig University and rose in the ranks of the Muslim Brotherhood. Although Morsi was not known as a dynamic candidate, the grassroots support provided by the Muslim Brotherhood helped him edge out Shafiq to become Egypt's first Islamic president. Promising to unite Egypt, Mosri resigned from his party upon assuming the presidency, but his close ties to the fundamentalist Islamic group and the instability of the Egyptian government made things difficult. After months of protests by anti-Morsi groups, there was a military coup in Egypt on 3 July 2013.