He has appeared on TV to sign a new power-sharing agreement with coup leader Gen Abdel Fattah al-Burhan amid continuing mass protests.
But the civilian coalition that nominated Mr Hamdok as PM two years ago refused to acknowledge any new deal.
The pact had been struck with a gun to his head, a spokesperson told the BBC.
“The future of the country will be determined by the young people on the ground,” Siddiq Abu-Fawwaz, from the Forces for Freedom and Change (FFC) coalition, told BBC’s Newshour programme.
On the streets of capital, Khartoum, the security forces have fired tear gas at protesters marching towards the presidential palace and demanding the military’s complete withdrawal from politics.
Since 25 October, when the military declared a state of emergency and dissolved the civilian leadership, at least 40 people have died in mass protests against the coup.
Mr Hamdok said he had agreed to the deal to stop the violence.
“Sudanese blood is precious, let us stop the bloodshed and direct the youth’s energy into building and development,” Reuters news agency quoted him as saying.
Under the agreement, the reinstated prime minister will lead a cabinet of technocrats until elections are held. But it is unclear how much power the new civilian government will have, as it it will be subject to military oversight.
Mr Hamdok told Al Jazeera the deal gave him complete freedom to form his government and hold elections before July 2023. It also allows the release of political prisoners.
The military has come under intense international and domestic pressure to restore the transition to democracy. The World Bank froze its aid to Sudan, and the African Union (AU) suspended the country’s membership of the bloc.
Western powers, including the US, UK and EU, have welcomed Mr Hamdok’s reinstatement and called for more political detainees to be freed.
The army entered into a fractious power-sharing arrangement with the FFC in August 2019, after long-time leader Omar al-Bashir was overthrown amid mass protests.
As part of that agreement, Gen Burhan had been due to step down as head of state, handing over to a civilian this month.
He says the army acted to prevent a civil war that was threatening to erupt because political groups had been inciting civilians against the security forces.
Mediators of the new agreement, which included academics, journalists and politicians, said the rules governing the transition towards democracy would be restored.
But questions are being asked about the military’s sincerity to do so, says BBC World Service Africa editor Mary Harper.
The fear is that continued instability in Sudan will further threaten the volatile Horn of Africa, she says.