The Mesopotamiam flood myth certainly came first. It is attested in the ancient stories of Gilgamesh, Atra-Hasis, and Ziusudra. The first mention of the flood seems to be in the earliest Gilgamesh stories (first written around 2100 BC), although the full flood story did not take shape until about 500 years later, incorporating elements from the Atra-Hasis story. While the Epic of Gilgamesh underwent several revisions over the centuries, it was certainly complete by about 1000 BC.
The biblical flood narrative was probably written during the Babylonian captivity, in the 6th century BC. While in Babylonia, the Judeans learned of the Mesopotamiam flood myth. They likely created multiple stories that were eventually conflated into the version that exists in the modern Bible.