The Soviet invasion of Afghanistan from 1979 to 1989 ultimately ended in stalemate, with the Soviets forced to withdraw after heavy losses. The invasion was an attempt to spread communism and create a friendly eastern state, but faced resistance from conservative Muslim Afghans opposed to Marxist rule. Guerilla warfare by Afghan mujahideen fighters weakened the Soviets over time and drove them to withdraw in 1989, though Afghanistan remained unstable. The costly war contributed to the decline and fall of the Soviet Union.