A military officer, he came to power after a military coup in 1969. Establishing a one-party state, with his Sudanese Socialist Union as the sole legal political entity in the country, Nimeiry pursued socialist and Pan-Arabist policies and close collaboration with Gamal Abdel Nasser of Egypt and Muammar Gaddafi of Libya. In 1971 Nimeiry survived a pro-Soviet coup attempt, after which he forged an alliance with Mao Zedong of China (who provided him with significant military and economic assistance), and, eventually, with the United States as well. In 1972 he signed the Addis Ababa Agreement, ending the First Sudanese Civil War. In his last years in power he also adopted aspects of Islamism, and in 1983 he imposed Sharia law throughout the country, precipitating the Second Sudanese Civil War. He was ousted from power in 1985 and went into exile in Egypt. He returned in 1999 and ran in the Presidential elections in 2000, but did poorly.