Informal negotiations for a Soviet withdrawal from Afghanistan had been underway since 1982. In 1988, the governments of Pakistan and Afghanistan, with the United States and Soviet Union serving as guarantors, signed an agreement settling the major differences between them known as the Geneva Accords. The United Nations set up a special Mission to oversee the process. In this way, Najibullah had stabilized his political position enough to begin matching Moscow's moves toward withdrawal. On July 20, 1987, the withdrawal of Soviet troops from the country was announced. The withdrawal of Soviet forces was planned out by Lt. Gen. Boris Gromov, who, at the time, was the commander of the 40th Army.
Among other things the Geneva accords identified the U.S. and Soviet non-intervention with internal affairs of Pakistan and Afghanistan and a timetable for full Soviet withdrawal. The agreement on withdrawal held, and on February 15, 1989, the last Soviet troops departed on schedule from Afghanistan.