Before the Soviet invasion, Afghanistan pursued a policy of neutrality and nonalignment rein its foreign relations, being one of a few independent nations to stay neutral in both World War I and World War II. In international forums, Afghanistan generally followed the voting patterns of Asian and African non-aligned countries. During the 1950s and 1960s, Afghanistan was able to use the Russian and American need for allies during the Cold War as a way to receive economic assistance from both countries. However, given that unlike Russia, America refused to give extensive military aid to the country, the government of Daoud Khan developed warmer ties with the USSR while officially remaining non-aligned. Following the coup of April 1978, the government under Nur Muhammad Taraki developed significantly closer ties with the Soviet Union and its communist satellites. After the December 1979 Soviet invasion, Afghanistan's foreign policy mirrored that of the Soviet Union. Afghan foreign policymakers attempted, with little success, to increase their regime's low standing in the noncommunist world. With the signing of the Geneva Accords, President Najibullah unsuccessfully sought to end the Democratic Republic of Afghanistan's isolation within the Islamic world and in the Non-Aligned Movement. Most Western countries, including the United States, maintained small diplomatic missions in the capital city ofKabul during the Soviet occupation. Many countries subsequently closed their missions due to instability and heavy fighting in Kabul after the Soviet withdrawal in 1989. Many countries initially welcomed the introduction of the Taliban regime, who they saw as a stabilizing, law-enforcing alternative to the warlords who had ruled the country since the fall of Najibullah's government in 1992. The Taliban soon became alienated of those countries' positive feelings with knowledge of the harsh Sharia law being enforced in Taliban-controlled territories spreading around the world. The brutality towards women who attempted to work, learn, or leave the house without a male escort caused outside aid to the war-torn country to be limited. Following the October 2001 American invasion and the Bonn Agreement the new government under the leadership of Hamid Karzai started to re-establish diplomatic relationships with many countries who had held close diplomatic relations before the communist coup d'état and the subsequent civil war. The Afghan government is focused on securing continued assistance for rebuilding the economy, infrastructure, and military of the country. It has continued to maintain close ties with North America, the European Union, South Korea, Japan, Australia, India, China, Russia and the Greater Middle East as well as African nations. It also seeks to establish relations with more South American or Latin nations. In late 2011, relations between Afghanistan and Dominican Republic were established.
During the Soviet occupation, the United Nations was highly critical of the U.S.S.R.'s interference in the internal affairs of Afghanistan and was instrumental in obtaining a negotiated Soviet withdrawal under the terms of the Geneva Accords. In the aftermath of the Accords and subsequent Soviet withdrawal, the United Nations has assisted in the repatriation of refugees and has provided humanitarian aid such as health care, educational programs, and food and has supported mine-clearing operations. The UNDP and associated agencies have undertaken a limited number of development projects. However, the UN reduced its role in Afghanistan in 1992 in the wake of fierce factional strife in and around Kabul. The UN Secretary General has designated a personal representative to head the Office for the Coordination of Humanitarian Assistance to Afghanistan and the Special Mission to Afghanistan, both based in Islamabad, Pakistan. Throughout the late 1990s, 2000, and 2001, the UN unsuccessfully strived to promote a peaceful settlement between the Afghan factions as well as provide humanitarian aid, this despite increasing Taliban restrictions upon UN personnel and agencies.