In Exodus 20:18-20, the Israelites are afraid to hear God directly on account of the thunder, lightning, trumpet blast, and smoking mountain that are accompanying his revelation. Moses tells the Israelites that God is doing this so that his fear may be before them, in order that they might not sin.
On pages 265-266 of Life of Moses, John Van Seters refers to two texts from the reign of the sixth century B.C.E. Babylonian king Nabonidus. One says: "Establish from heaven the fear ([puluchti]) of Sin, the lord of the gods, in the heart of his people. May they not commit any sin ([chititi)] and may their foundations be firm." The second one says: "[O Sin], establish the fear of your great godhead in the heart of your people, so that they do not commit any sin ([la ichattu]) against your great godhead. May their foundations be as firm as heaven."
Van Seters notes three similarities between these texts and Exodus 20:18-20. First, the fear "of the gods in Babylonian religion is often associated with their terrifying splendor..." We see such terrifying splendor in Exodus 20:18. Second, in both, the god attempts to instill fear into the people. And, third, the first prayer requests that the fear of sin be established "from heaven," and, in Exodus 20:22, God speaks to the Israelites "from heaven."
Van Seters concludes: "...the role of Nabonidus is similar to Moses in that he acts as intermediary or intercessor in his prayer on behalf of the people. The correspondence with late Neo-Babylonian piety is quite remarkable and fits precisely with our dating of the Yahwist."
But does anything like this also appear in earlier ancient Near Eastern texts?