Mohammed Zahir Shah, Nadir Shah's 19-year-old son, succeeded to the throne and reigned from 1933 to 1973. Until 1946 Zahir Shah ruled with the assistance of his uncle, who held the post of Prime Minister and continued the policies of Nadir Shah. Another of Zahir Shah's uncles, Shah Mahmud Khan, became Prime Minister in 1946 and began an experiment allowing greater political freedom, but reversed the policy when it went further than he expected. In 1953, he was replaced by Mohammed Daoud Khan, the king's cousin and brother-in-law. Daoud sought a closer relationship with the Soviet Union and a more distant one towards Pakistan. Afghanistan remained neutral and was not a participant in World War II, nor aligned with either power bloc in the Cold War. However, it was a beneficiary of the latter rivalry as both the Soviet Union and the United States vied for influence by building Afghanistan's main highways, airports and other vital infrastructure. By the late 1960s many western travelers were using these as part of the hippie trail. In 1973, Zahir Shah's brother-in-law, Daoud Khan, launched a bloodless coup and became the first President of Afghanistan while Zahir Shah was on an official overseas visit. Daoud Khan tried to implement some much needed reforms especially in the economic sector.
In 1978, a prominent member of the People's Democratic Party of Afghanistan (PDPA), Mir Akbar Khyber, was allegedly killed by the Daoud government. Leaders of the PDPA feared that Daoud was planning to dismantle them because many were being arrested. Hafizullah Amin along with other PDPA members managed to remain at large and organised an uprising. The PDPA, led by Nur Mohammad Taraki, Babrak Karmal and Hafizullah Amin, overthrew the regime of Mohammad Daoud, who was assassinated along with his family during the April 1978 Saur Revolution. Taraki was declared President, Prime Minister and General Secretary of the PDPA. Once in power, the PDPA implemented a socialist agenda. It moved to carry out an ill-conceived land reform, which was misunderstood by virtually all Afghans. They also imprisoned, tortured or murdered thousands of members of the traditional elite, the religious establishment, and the intelligentsia. They also prohibited usury and made a number of statements on women's rights, by declaring equality of the sexes and introducing women to political life. Anahita Ratebzad was one of several female Marxist leaders and a member of the Revolutionary Council.
As part of its Cold War strategy, the White House in the United States began recruiting, financing and arming Mujahideen fighters during Operation Cyclone in 1979, which was aimed to defeat the Soviets. President Jimmy Carter's National Security Advisor, Zbigniew Brzezinski, warned at the time that this might prompt a Soviet intervention. In March 1979, Hafizullah Amin took over as prime minister, retaining the position of field marshal and becoming vice-president of the Supreme Defence Council. Taraki remained President and in control of the army until September 14 when he was killed.
To bolster the Parcham faction, the Soviet Union decided to intervene on December 24, 1979, when the Red Army invaded its southern neighbor. Over 100,000 Soviet troops took part in the invasion, which was backed by another one hundred thousand Afghan military men and supporters of the Parcham faction. In the meantime, Hafizullah Amin was killed and replaced by Babrak Karmal. In response to the Soviet occupation of Afghanistan, the Reagan administration in the U.S. increased arming and funding of the Mujahideen who began a guerilla war thanks in large part to the efforts of Charlie Wilson and CIA officer Gust Avrakotos. Early reports estimated that $6–20 billion had been spent by the U.S. and Saudi Arabia but more recent reports state that the U.S. and Saudi Arabia provided as much as up to $40 billion in cash and weapons, which included over two thousand FIM-92 Stinger surface-to-air missiles, for building up Islamic groups against the Soviet Union. The U.S. handled most of its support through Pakistan's ISI. Saudi Arabia was also providing financial support. Leaders such as Ahmad Shah Massoud received only minor aid compared to Hekmatyar and some of the other parties.
The 10-year Soviet occupation resulted in the killings of between 600,000 and two million Afghans, mostly civilians. About 6 million fled as Afghan refugees to Pakistan and Iran, and from there over 38,000 made it to the United States and many more to the European Union. Faced with mounting international pressure and great number of casualties on both sides, the Soviets withdrew in 1989. Their withdrawal from Afghanistan was seen as an ideological victory in America, which had backed some Mujahideen factions through three U.S. presidential administrations to counter Soviet influence in the vicinity of the oil-rich Persian Gulf. The USSR continued to support President Mohammad Najibullah until 1992.