From RAND Coporation:
Terrorists can operate in many environments. Al Qaeda cells have existed in hostile states with efficient law enforcement capabilities, like the United States or Germany. Terrorist organizations have a much easier time operating in states with low capability, even when those states are hostile to them. Examples would be Yemen or Nigeria. Terrorists have an easier time operating in ungoverned space, where little or no state apparatus exists, such as Somalia. But an even better place for terrorists to locate their home base is in a state that is sympathetic to their purposes. And the best place of all would be a state the terrorists actually controlled. In that environment they would not only be free of state interference, they would actually be able to employ the attributes of sovereignty to their purposes—the police, the security services, the banking system, the diplomatic establishment. Imagine the difficulty of dealing with terrorists with diplomatic immunity.