NATO has begun withdrawing its troops from Afghanistan, according to an alliance official, after nearly 20 years of war.