The Soviet Union invaded Afghanistan in 1979 to prop up the communist government that came to power after a 1978 revolution. However, many Afghans opposed communist rule and fought back as mujahedeen rebels in a civil war. The Soviet invasion was intended to ensure communist control and give the Soviets access to oil, but they faced guerrilla warfare tactics from the mujahedeen. After 10 years of fighting, the costly and unwinnable war became a disaster for the Soviets similar to the US in Vietnam, and Soviet troops withdrew in 1989.