CAIRO (Updated) - Egypt's Prime Minister Ahmed Shafiq resigned on Thursday and the military asked a former transport minister to form a new government which pro-democracy activists hope will be purged of Hosni Mubarak's old guard. Shafiq was appointed prime minister by Mubarak in his final days in office before he was ousted on Feb. 11 after an 18-day popular uprising which shook the Middle East. There have since been protests and political pressure for Shafiq to step down. One Shafiq aide said appointing Essam Sharaf prime minister was timed to defuse calls for another mass demonstration on Friday after a first modest reshuffle by Shafiq failed to mollify protesters who want a clean break with the Mubarak era. "This is a shocking and premature resignation. There have been pressures from the streets that he quit," one of Shafiq's aides told Reuters, asking not to be identified. "There was fear of Friday's protests and how big they may be. He actually wanted to leave before this week as well and does not want to agitate the people," the aide said. The Muslim Brotherhood and other political groupings had also been calling for Shafiq and his government to step aside and the army, in an apparent response had vowed to halt any "counter-revolution" from hijacking Egypt's revolution. The uprising in Egypt, a key US ally with a peace treaty with Israel, fuelled revolts against other autocrats in the region. Progress towards democracy in the Arab world's most populous nation will also have an affect on its neighbours. The key jobs of foreign, interior and justice ministers were also likely to be reshuffled shortly, security sources said, to cleanse the government of further of links to Mubarak. Ever since Mubarak's overthrow, hundreds of thousands of Egyptians have turned out in Cairo's Tahrir Square and other cities to celebrate his downfall and send a message to the military that the people will not be ignored. Protesters, some of whom have erected tents in Tahrir Square, greeted the news of Shafiq's resignation with jubilation and relief. They applauded the armed forces for meeting their demands and chanted: "The people and the army are united." The crowds in Tahrir Square welcomed Sharaf as premier. But not everyone was as positive. "This is a change for the worse not for the better," said Hassan Nafaa, a political scientist at Cairo University who also actively campaigned against Mubarak. "Shafiq left but the one who has been installed has no political vision or anything to do with politics. There are other interests being secured that are thwarting change," he added. Shafiq, an air force commander, has been tipped by one military source as a potential contender for the presidency in a forthcoming election. This would ensure the armed forces would have one of their own members in Egypt's top post. Some analysts had suggested Shafiq would resign well before a presidential election, expected in the second half of the year as part of reforms promised by the military, to provide a suitable gap for him to prepare for his bid for the presidency. But one of Shafiq's aides dismissed such an idea after Thursday's resignation, saying he did not expect him to stand. Activists had demanded a new line up of technocrats as ministers after 30 years of Mubarak's rule. The cabinet will act as an interim government while Egypt holds a referendum on constitutional amendments in March, a parliamentary vote in June and a presidential election about six weeks after that. "The Supreme Military Council had said publicly ... that the current government would be out before the parliamentary and presidential elections. Shafiq's resignation is part of that purging process," a security source told Reuters. Nabil Abdel Fattah, a researcher at the al-Ahram Centre for Political and Strategic studies, said: "Shafiq had to leave because he was a symbol of the old regime and he underestimated the masses of angry revolutionary youth." Reform to the constitution will make it much easier for Egyptians to run for the presidency, removing requirements which made it almost impossible for anyone but the ruling party and representatives of weak opposition parties to field candidates. Some opposition figures are concerned that a rush towards elections is not in the best interests of democratic change. Mubarak's administration had suppressed opposition groups for decades and they say they need time to regroup. They say only the Muslim Brotherhood, which was formally banned under Mubarak, is in the position to mount an election campaign, though the group says it will not seek a majority in parliament or the presidency. A quick election will also suit the remnants of the National Democratic Party, the ruling party which had dominated parliament under Mubarak and whose headquarters on the bank of the Nile were burned down during the revolution.