CASABLANCA—A decade ago, the U.S. released three hardened Moroccan militants from Guantanamo and turned them over to the Moroccan government on the assumption they wouldn't return to the battlefield.

They wound up leading one of the most violent Islamist groups fighting in Syria's civil war.

Their story serves as a cautionary tale days after...