Thousands of people marched against a recent deal he had done to share power with the army, who staged a coup in October.
Chanting “power to the people”, protesters called for a return to full civilian rule. But military forces again responded with force, leaving two people dead.
Mr Hamdok’s decision to quit leaves the army in full control.
It is another blow to Sudan’s fragile attempts at a transition to democratic rule after a popular uprising led to the overthrow of Sudan’s long-term authoritarian President Omar al-Bashir in 2019.
In a televised address, Mr Hamdok said the country was at a “dangerous turning point that threatens its whole survival”.
He said he had tried his best to stop the country from “sliding towards disaster”, but that “despite everything that has been done to reach a consensus… it has not happened”.
Civilian and military leaders had made an uneasy power-sharing agreement after the army staged a coup on 25 October and initially placed Prime Minister Hamdok under house arrest.
The country was just one month away from transition to a civilian head of state when the army seized power.
Mr Hamdok, an economist by training, is widely respected in the international community has previously worked as an official with the United Nations. He helped negotiate a deal to forgive some of Sudan’s debts but this involved removing fuel subsidies, leading the prices of many basic goods to rise, and to anti-government protests.
Under the agreement reached with Mr Hamdok in November, the reinstated prime minister was supposed to lead a cabinet of technocrats until elections were held. But it was unclear how much power the new civilian government would have, and protests against the military resumed, which were often violently suppressed.
Protests continued even after Mr Hamdok had returned to office, with some demonstrators saying that his reinstatement was helping to legitimatize the military takeover.
Reacting to Mr Hamdok’s resignation, the United States urged Sudan’s leaders to end violence against anti-military demonstrators.
More than 50 people have been killed during protests since the coup, including at least two on Sunday, according to the pro-democracy Sudan Central Doctors’ Committee.
The resignation of Mr Hamdok showed the military was losing their leverage to get international recognition and popular support, according to a spokesman for the opposition Sudanese Congress Party.
Thousands of people were on the streets of the capital Khartoum and the city of Omdurman on Sunday, chanting and calling on the military to leave politics.
AGENCIES