Mr Hamdok took over the highest state office at the presidential palace in the capital Khartoum, state broadcaster Sudan TV reported.
A few minutes earlier, Mr Hamdok and military ruler, Abdel Fattah al-Burhan, had signed an agreement for a new transitional government.
“We will put our country back on the right track,’’ Hamdok promised.
The agreement has reopened the way to democracy, he added.
According to the agreement, Mr Hamdok will be allowed to form a cabinet with civilian representatives.
Mr Al-Burhan, however, will head the new interim government together with Mr Hamdok as leader of the Sovereign Council.
The Sovereign Council also includes representatives of the military.
Additionally, all political prisoners, detained in the wake of the Oct. 25 coup, will be released.
The agreement to reset the political clock in Sudan came after extended negotiations between the leaders of the military coup and civil society representatives.
Mr Hamdok had been held under house arrest since the coup.
It initially remained unclear whether military representatives would also be part of the new government.
Mr Hamdok was installed as transitional prime minister in 2019 after protests toppled former dictator Omar al-Bashir, who had ruled the country for decades.
Mr Hamdok’s government was originally tasked with organising elections that would have seen the military make way for a civilian government.
During the transition, the country was ruled by the Sovereign Council, which included both military and civilian members.
That agreement appeared to have been ripped up last month when Mr al-Burhan dissolved the government, put Hamdok under house arrest and declared a national emergency, however.
In recent weeks, there have been repeated protests by thousands of Sudanese citizens demanding more democracy and a civilian government in the country with 44 million inhabitants.
At least 15 people died in a recent round of protests after troops fired into a crowd.
Another mass protest is planned for Sunday in the capital Khartoum.
The international community is also demanding the restoration of constitutional order.