The attack jolted a country where the killing of police officers on duty is rare.