In 1899 he fought in the last campaign of the Mahdist forces, whose strength had been broken in the previous year at Omdurman. At the Battle of Umm Diwaykarat he was injured, but was the only leader who escaped and continued the resistance. He tried to reach safety in the Hejaz, but on 19 January 1900, he was captured near Tokar and sent as a prisoner to Rosetta. He served in prison for eight years and after his release stayed in Egypt until he died in 1926.