Both Gilgamesh and Genesis contain an account of a great flood, sent to destroy humanity. Genesis says that God had become so angry with his creation that he resolved to destroy it:
The Lord saw how great the wickedness of the human race had become on the earth...So the Lord said, “I will wipe from the face of the earth the human race I have created—and with them the animals, the birds and the creatures that move along the ground—for I regret that I have made them.”
Of course, he spared the righteous Noah and the members of his family, as well as the animals that he took with him on the ark. Gilgamesh describes a similar story in which the gods, irritated with mankind, attempt to destroy everyone with a flood. But in this story, the goddess Ea warns Utnapishtim of the impending disaster. Utnapishtim, like Noah, builds a ship and rides out the flood with his family and animals. Utnapishtim is granted immortality by the remorseful gods after the flood. The parallels between these two passages (and other parallel flood stories from other ancient civilizations in the general area) are obvious. Both speak to the power (and the mercy) of the divine and the relationship of the gods/God with mankind. Both also evoke the tenacity of human existence, even in the most horrific of circumstances.
The flood stories in Genesis and Gilgamesh are so similar that most qualified scholars suggest the Genesis flood story is based on the framework of the older Mesopotamian myth. The most striking of the many parallels are the episode of the sending out of the birds and the anthropomorphic description of the gods savoring the aroma of post diluvian sacrifices. No other ancient flood story exhibits such close, detailed parallels with the one in Genesis.
The occasion of the Babylonian exile in the sixth century BCE provides both the perfect opportunity and a logical explanation for the literary borrowing in Genesis. Fundamentalists aside, most scholars date the writing or redaction of Genesis to the fifth or sixth centuries BCE. Furthermore, the early chapters of Genesis are infused with Mesopotamian references and literary allusions. However, rather than simply borrowing, Genesis modifies and subverts the foundation myths of Babylonia in polemical fashion. The long and pompous Babylonian Creation Story in which Marduk the patron god of Babylon brings about an ordered cosmos by violent conquest becomes a brief, elegant and irenic tale in Genesis one. The temptation and civilization of a primitive man by a city prostitute in Gilgamesh becomes a tragic loss of paradise and immortality when Adam and Eve are forced to leave their garden home in an anticipatory parable of exile. The expansionist designs of the ancient king of Uruk who wants to unite the region by language and religion in "Enmerkar and the lord of Aratta" becomes a mocking tale of hubris and frustrated imperial ambition in the Genesis story of the city of Babel. Similarly, the flood that in Gilgamesh is a tragic and unjust punishment on innocent humanity becomes divine judgement on a a corrupt and violent civilization in Genesis, evoking the historical fall of the neo Babylonian empire.