But it has struggled to cope with a rising tide of Islamist militants and the prosecution of Islamist sleeper cells, especially after four deadly attacks in 2015-2016, including on foreign tourists, the country’s economic lifeblood.