A New York City police officer was killed on Wednesday in the Bronx by a gunman who was then shot and killed by police as he ran from the scene, police said.