The attacker, believed to be a Moroccan citizen with US residency, was shot dead at the scene.