Afghan security forces killed two gunmen who attacked the American University in Kabul, police said early on Thursday, ending an assault on the compound that killed at least one person and sent hundreds of students fleeing in panic.