In the beginning God created the heaven and the earth. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
The Bible tells us that in the beginning God existed in the darkness of space and water existed. The creation was created from this water. Matter was not created from nothing, it was pre-existent as water.