The American ambassador to Afghanistan is leaving his post after two years in Kabul, the State Department announced on Monday.