People were, according to Middle Eastern beliefs, created for the benefit of the gods: they were to serve and obey, provide the gods with food, clothing, and shelter, and offer them reverence. There were personal gods who were protective of the individual and linked humans with the great deities, but essentially the ancient Mesopotamian peoples were at the mercy of gods whose behavior was arbitrary and often abusive. In response to this belief in negligence on the part of the gods, various city-states enacted public laws or codes of ethics (in addition to promulgating a large body of wisdom literature) that sought to promote justice and truth and to destroy wickedness. Of these law collections the most famous was probably the code of Hammurabi.
While originally the functions of priesthood were borne by the city rulers, in later times priests became a separate group and were assigned special and significant duties: some pacified the gods with hymns and liturgy; others were trained in divination and astrology (special functions in Middle Eastern religion that indirectly contributed to the growth of science); others—perhaps the most important—were concerned with protecting people from demons, who were considered actual creatures with distinct shapes and names and were to be repelled by magic, daily recitations, and exorcism.