Cairo - Egyptian president Mohamed Morsi has rejected calls for his resignation, saying that he is Egypt’s "guardian of legitimacy" after three days of nationwide pro- and anti-government demonstrations, that have drawn millions to the streets.

His speech was a response to the protests, and to an ultimatum from Egypt’s military, which on Tuesday said it would issue a political "road map" unless Morsi resolved the crisis in 48 hours. Morsi had earlier dismissed the ultimatum, demanding in a message posted on Twitter that the army rescind it.

In his televised speech on Tuesday night, Morsi accused members of former president Hosni Mubarak’s regime of trying to topple his government and undermine the revolution.

"There is no substitute for legitimacy," Morsi said in the 45-minute late-night address. "The revolution of January 25 will achieve its goals. Legitimacy will be safeguarded, and I am willing to give my own life to protect it."

Just hours after his speech, the health ministry reported that unidentified gunman had killed 18 people and wounded at least 200 more after opening fire on a rally of his supporters in the capital.

At least seven other people were killed and dozens more injured in clashes in Cairo between the president's supporters and opponents.

Morsi’s speech was received with a mix of anger and disbelief among the vast crowd of protesters gathered outside the presidential palace.

His remarks were punctuated several times by loud chants of "irhal!" - "leave!"

"Legitimacy? It’s like he was trying to convince himself," said demonstrator Nader Amer.

The president invoked the idea of legitimacy dozens of times in his speech, saying that he was obligated as Egypt’s first democratically-elected president to remain in office.

"What legitimacy? Look around, look at the millions in Cairo and the governorates," he said, referring to the anti-government protesters gathered nationwide.

The president’s speech was greeted with cheers in Cairo’s Nasr City neighbourhood, however, where thousands of his supporters have been staging a sit-in since Friday.

'Back to dictatorship'

The army has not specified what it will do once it’s 48 hour ultimatum issued on Monday expires.

Details of the army’s proposed "road map" were leaked to the Reuters news agency on Tuesday. It would reportedly dismiss what remains of the parliament - the lower house was dissolved by court order last year - and suspend the constitution pending new elections.

Morsi met on Tuesday with General Abdel Fattah al-Sisi, the defence minister and army chief. The presidency has said it had no knowledge of the army’s ultimatum before it was issued.

He urged his supporters to remain non-violent, and rejected calls for "jihad" (holy war) by some of his supporters, saying that it should only be conducted against "enemies outside the state".

He added, however, that he was willing to "sacrifice my blood for the sake of stability and security of this homeland".

Khaled Daoud, a spokesman for the National Salvation Front, the largest formal opposition bloc in Egypt, called that a "clear incitement for civil war".

Morsi offered no concrete concessions in his speech. He mentioned proposals to dismiss the cabinet and install a technocratic government, and to create a committee to amend the constitution, which was approved by a public referendum last year. But he said the opposition had already rejected those demands, and beyond that only offered more "national dialogue", which his opponents have already rejected.

His offer will not assuage public anger, not with hundreds of thousands of people taking to the streets for a third night to demand his resignation.

Morsi continues to lose support from within his government as well. Foreign Minister Kamel Amr tended his resignation, becoming the sixth minister to quit within the past 48 hours. Two of Morsi’s presidential spokesmen also quit.

On Monday Sami Enan, his military adviser, resigned and said the army would not "abandon the will of the people".

"The Muslim Brotherhood has only their supporters, and they're staying behind him, but outside the core he's weakened," said Khaled Fahmy, an Egyptian historian and activist. "People are abandoning ship."