No immediate explanation was given for the return of the former prime minister who spent his time in exile in several countries, including Egypt and Britain.
A fixture of Sudanese politics since the 1960s, Mahdi was prime minister from 1966 to 1967 and again from 1986 to 1989.
His government was the last one to be democratically elected in Sudan, before it was toppled by a 1989 coup launched by current President Omar al-Bashir.
He briefly returned to Khartoum in January 2017 after more than two years of exile in Cairo, but had since returned to the Egyptian capital.
In April Sudanese media reported that the state security prosecutor had charged Mahdi with collaborating to overthrow Bashir after a meeting with rebel leaders in Paris.
Since the coup that ousted Mahdi’s civilian government, the ex-premier’s Umma Party has acted as Sudan’s main opposition group and has regularly campaigned against the policies of Bashir’s government.