Desertion
Over the course of the war, the Soviets executed 158,000 troops for desertion.

Soviet–Afghan War: Many Soviet soldier deserters of the Soviet–Afghan War  explain their reasons for desertion as political and in response to internal disorganization and disillusionment regarding their position in the war. Analyses of desertion rates argue that motivations were far less ideological than individual accounts claim. Desertion rates increased prior to announcements of upcoming operations, and were highest during the summer and winter. Seasonal desertions were probably a response to the harsh weather conditions of the winter and immense field work required in the summer. A significant jump in desertion in 1989 when the Soviets withdrew from Afghanistan may suggest a higher concern regarding returning home, rather than an overall opposition towards the war itself.

Inter-ethnic explanation for desertion: In the beginning of the Soviet invasion, the majority of Soviet forces were soldiers of Central Asian republics. The Soviets believed that shared ideologies between Muslim Central Asians and Afghan soldiers would build trust and morale within the army. However, Central Asians' longstanding historical frustrations with Moscow degraded soldiers' willingness to fight for the Red Army. As Afghan desertion grew and Soviet opposition was strengthened within Afghanistan, the Soviet plan overtly backfired.
The personal histories of Central Asian ethnic groups – especially between Pashtuns, Uzbeks, and Tajiks, caused tension within the Soviet military. Non-Russian ethnic groups easily related the situation in Afghanistan to Communist takeover of their own states' forced induction into the USSR. Ethnic Russians suspected Central Asians of opposition, and fighting within the army was prevalent.
Upon entering Afghanistan, many Central Asians were exposed to the Qur’an for the first time uninfluenced by Soviet propagandist versions, and felt a stronger connection towards the opposition than their own comrades. The highest rates of desertion were found among border troops, ranging from 60 to 80% during the first year of the Soviet invasion. In these areas, strong ethnic clashes and cultural factors influenced desertion.
As Afghan soldiers continued to desert the Soviet army, a united Islamic Alliance for the Liberation of Afghanistan began to form. Moderates and fundamentalists banded together to oppose Soviet intervention. The Islamic ideology solidified a strong base of opposition by January 1980, overriding ethnic, tribal, geographic and economic differences among Afghans willing to fight the Soviet invasion, which attracted Central Asian deserters. By March 1980, the Soviet army made an executive decision to replace Central Asian troops with the European sectors of the USSR to avoid further religious and ethnic complications, drastically reducing Soviet forces.

Soviet disillusionment upon entering the war: Soviet soldiers entered the war under the impression that their roles were primarily related to the organization of Afghan forces and society. Soviet media portrayed the Soviet intervention as a necessary means of protecting the Communist uprising from outside opposition. Propaganda declared that Soviets were providing aid to villagers and improving Afghanistan by planting trees, improving public buildings and "generally acting as good neighbors". Upon entering Afghanistan, Soviet soldiers became immediately aware of the falsity of the reported situation.
In major cities, Afghan youth that originally supported the leftist movement soon turned to Soviet oppositional forces for patriotic and religious reasons. The opposition built resistance in cities, calling Soviet soldiers infidels that were forcing an imperialist Communist invasive government on Afghanistan's people. As Afghan troops continued to abandon the Soviet army to support the mujahideen, they became anti-Russian and antigovernment. Opposition forces emphasized the Soviets' atheism, demanding support for the Muslim faith from civilians. The hostility shown towards soldiers, who entered the war believing their assistance was requested, grew defensive. The opposition circulated pamphlets within Soviet camps stationed in cities, calling for Afghan freedom from the aggressive Communist influence and a right to establish their own government.
The native Afghan army fell from 90,000 to 30,000 by mid-1980, forcing Soviets into more extreme combative positions. The mujahideen's widespread presence among Afghan civilians in rural regions made it difficult for Soviet soldiers to distinguish between the civilians they believed they were fighting for and the official opposition. Soldiers who had entered the war with idealistic viewpoints of their roles were quickly disillusioned.

Problems in Soviet army structure and living standards: The structure of the Soviet army, in comparison to the mujahideen, set the Soviets at a serious fighting disadvantage. While the mujahideen structure was based on kinship and social cohesion, the Soviet army was bureaucratic. Because of this, mujahideen could significantly weaken the Soviet army by the elimination of a field commander or officer. Resistance forces were locally based, more ready to address and mobilize the Afghan population for support. The Soviet army was centrally organized; its regime structure emphasized rank and position, paying less attention to the well-being and effectiveness of its army.
The initial Soviet plan relied on Afghan troops' support in the mountainous regions of Afghanistan. The majority of the Afghan army support crumbled easily as forces lacked strong ideological support for Communism from the beginning.
The Afghan army, comprising 100,000 men before 1978, was reduced to 15,000 within the first year of the Soviet invasion. Of the Afghan troops that remained, many were considered untrustworthy to Soviet troops. Afghans that deserted often took artillery with them, supplying the mujahideen. Soviet troops, to fill Afghan soldiers' place, were pushed into mountainous tribal regions of the East. Soviet tanks and modern warfare was ineffective in the rural, mountainous regions of Afghanistan. Mujahideen tactics of ambush prevented Soviets from developing successful counterattacks.
In 1980, the Soviet army began to rely on smaller and more cohesive units, a response to mirror mujahideen tactics. A decrease in unit size, while solving organizational issues, promoted field leaders to head more violent and aggressive missions, promoting Soviet desertion. Often, small forces would engage in rapes, looting, and general violence beyond what higher ranks ordered, increasing negative sanctions in undesirable locations.
Within the Soviet army, serious drug and alcohol problems significantly reduced the effectiveness of soldiers. Resources became further depleted as soldiers pushed into the mountains; drugs were rampantly abused and available, often supplied by Afghans. Supplies of heating fuel, wood, and food ran low at bases. Soviet soldiers often resorted to trading weapons and ammunition in exchange for drugs or food. As morale decreased and infections of hepatitis and typhus spread, soldiers became further disheartened.

Soviet deserters to the mujahideen: Interviews with Soviet soldier deserters confirm that much of Soviet desertion was in response to widespread Afghan opposition rather than personal aggravation towards the Soviet army. Armed with modern artillery against ill-equipped villagers, Soviet soldiers developed a sense of guilt for the widespread killing of innocent civilians and their unfair artillery advantage. Soviet deserters found support and acceptance within Afghan villages. After entering the mujahideen, many deserters came to recognize the falsity of Soviet propaganda from the beginning. Unable to legitimize the unnecessary killing and mistreatment of the Afghan people, many deserters could not face returning home and justifying their own actions and the unnecessary deaths of comrades. Upon deserting to the mujahideen, soldiers immersed themselves into Afghan culture. Hoping to rectify their position as the enemy, deserters learned the Afghan language and converted to Islam.

United Kingdom: Historically, one who was paid to enlist and then deserted could be arrested under a type of writ known as arrestando ipsum qui pecuniam recepit, or "For arresting one who received money".

Napoleonic Wars: During the Napoleonic Wars desertion was a massive drain on British army resources, despite the threat of court martial and the possibility of capital punishment for the crime. Many deserters were harboured by citizens who were sympathetic to them.

First World War: "306 British and Commonwealth soldiers were executed for...desertion during World War I," records the Shot at Dawn Memorial. Of these, 25 were Canadian, 22 Irishmen and five New Zealanders.
"During the period between August 1914 and March 1920 more than 20,000 servicemen were convicted by courts-martial of offences which carried the death sentence. Only 3,000 of those men were ordered to be put to death and of those just over 10% were executed."

Second World War: Throughout the Second World War, almost 100,000 British and Commonwealth troops deserted from the armed forces. Capital punishment for desertion was abolished in 1930 so most were imprisoned.

Iraq War: On 28 May 2006, the UK military reported over 1,000 absent without leave since the beginning of the Iraq War, with 566 missing from 2005 and that part of 2006. The Ministry of Defence said that levels of absence were fairly constant and "only one person has been found guilty of deserting the Army since 1989".