In the Epic of Gilgamesh, humanity and the divine are inextricably intertwined. The gods repeatedly intervene in the lives of men when their actions make them angry, and Gilgamesh himself is part divine. What is more, the gods are associated with physical places and people, for whom they act as patrons. Shamash is Gilgamesh's patron, for example, and Anu takes care of the town of Uruk.
The gods, like those in Greek mythology, are constantly scheming and plotting against each other, and people are often the unwitting victims, caught up in these mighty struggles. Likewise, they often hold humans collectively responsible for the offenses of just one person. When Gilgamesh spurns the goddess Ishtar's amorous advances, for example, she persuades her parents to unleash a divine bull on Uruk.
In addition, the famous Flood itself, noted for its similarity to the Noahic story from the Old Testament, is the result of wrathful gods, angry, essentially, that mankind is too loud and clamorous. Only Utnapishtim, warned ahead of time by the goddess Ea to "take up into [a] boat the seed of all living creatures," survives with his family. Utnapishtim is rewarded with immortality for his exertions. The relationship between mortals and gods, therefore, is often contentious, and those who have not been chosen as favorites by the deities are condemned to suffer.
Although the Epic of Gilgamesh was not a theological work per se, it reflects many of the religious beliefs of its period, allowing the reader to infer many things about how people related to their gods in ancient Mesopotamia.
First, it shows a polytheistic religion in which the gods often disagree among themselves about issues concerning mortals. The gods are anthropomorphic and interbreed with mortals, with some mortals having partially divine ancestry. The gods are more powerful than mortals, but they are still similar in nature to humans in character, prone to favoritism and prejudice, just like powerful human rulers. Humans fear the anger of gods due to this power but also try hard to curry favor with the gods to benefit from the gods' power.
Another quality of the relationship is one described in Latin as "do ut des" or "I give that you might give." Humanity's relationship with the divine is often portrayed as a form of favor exchange.
Kings are shown as having a duty to mediate between the divine and the human, creating and enforcing laws that reflect divine will. Thus kings are expected to be just; Gilgamesh's behavior at the beginning of the book is outrageous precisely because it violates this duty.