Planning for the withdrawal of the Soviet Union (USSR) from the Afghanistan War began soon after Mikhail Gorbachev became the General Secretary of the Central Committee of the Communist Party of the Soviet Union. Under the leadership of Gorbachev, the Soviet Union attempted to consolidate the PDPA's hold over power in the country, first in a genuine effort to stabilize the country, and then as a measure to save face while withdrawing troops. During this period, the military and intelligence organizations of the USSR worked with the government of Mohammad Najibullah to improve relations between the government in Kabul and the leaders of rebel factions.
The diplomatic relationship between the USSR and the United States improved at the same time as it became clear to the Soviet Union that this policy of consolidating power around Najibullah's government in Kabul would not produce sufficient results to maintain the power of the PDPA in the long run.
The Geneva Accords, signed by representatives of the USSR, the USA, the Islamic Republic of Pakistan and the Republic of Afghanistan (thus renamed in 1987) on 14 April 1988, provided a framework for the departure of Soviet forces, and established a multilateral understanding between the signatories regarding the future of international involvement in Afghanistan. The military withdrawal commenced soon after, with all Soviet forces leaving Afghanistan by 15 February 1989.