The killing of the U.S. ambassador to Libya and three other Americans, in one of the most brazen attacks on a U.S. diplomatic compound in a generation, sparked a security crisis in the North African country, elevated tensions across the Middle East and raised concerns about how well the U.S. can protect its diplomats abroad.