Andrew F. March and Mara Revkin have a fascinating analysis in Foreign Affairs of the legal underpinnings of the Islamic State (ISIS)'s efforts to build an Islamic Caliphate state. They note that ISIS is governing millions of people and sees itself as building an authentic legal order based upon a "social contract with the Muslim population it aspires to govern." For example, ISIS has issued administrative guidelines for groups wishing to pledge allegiance to the caliphate, set up courts and has criminalized threats against the state and public order, crimes against religion or public morality and crimes or torts against particular individuals.
Here's a good excerpt on ISIS' theory of governance: "The caliph is seen as a custodian of divine law. His power is not portrayed as absolute, but he does have plenty of room to issue laws and policies. The system follows a classical Islamic theory of statecraft known as siyasa sharʿiyya. The term means “religiously legitimate governance,” but it implies more than just the application of formal sharia. Instead, it sets up a kind a dualistic model of law and governance. On the one hand, the system requires sharia courts for the application of Islamic legal rules in routine matters for which specific rules exist. But it recognizes that rules do not exist for every conceivable matter. And so the 'siyasa sharʿiyya' theory posits that there are legitimate authorities—from market inspectors to military commanders and governors up to the caliph himself—that have the right to make lawlike decisions as long as those decisions are issued solely with the welfare (maslaha) of the Muslim community in mind and do not violate known laws."