As more layers of sediment build up on top, the sediment around the skeleton begins to compact and turn to rock. The bones then start to be dissolved by water seeping through the rock. Minerals in the water replace the bone, leaving a rock replica of the original bone called a fossil.