The origins of the Sabbath are obscure; there are no contemporary parallels in ancient Near Eastern practices. On the other hand, the Bible gives two contradictory accounts for its origin. Both Genesis 2:2-3 and Exodus 20:8-11 claim that its origin is
because for six days Yahweh made the heavens and the earth, the sea, and everything that is in them, and he rested on the seventh day. On account of this, Yahweh blessed the Sabbath day and made it holy.
The last sentence here is a direct reference to the Priestly creation account (Gen 2:3). Whoever authored this origin for the Sabbath—bear in mind that Ex 20:11 is merely a part of its immediate context, the Ten Commandments (Ex 20:1-17)—was familiar with P’s text or the textual tradition from which P itself was composed.
Deuteronomy 5:12-15, however, which is a part of a duplicate rendition of the Ten Commandments in the Deuteronomic source (Deut 5:6-18), accredits a different origin to the Sabbath: