Sefer HaBahir 24
1Rabbi Yanai said, “The Earth was created before the Heavens, as it is said, ‘[In the day of YHVH God’s making of the] Earth and the Heavens' (Genesis 2:4).’”They said to him, “Isn’t it written ‘[In the beginning, God created] the Heavens and the Earth’ (Genesis 1:1)?” He said to them, "To what does this compare? To a king who acquires a beautiful object, but it was not complete, so he did not give it a name. He said, ‘I will complete it and prepare its pedestal and accessories, and then I will give it a name.’ Thus it is written, ‘From eternity You established the Earth’ (Psalms 102:6), and afterward ‘And Heaven is the work of Your hands’ (Psalms 102:26). And it says, ‘He covered Himself with a garment of light, spread out the Heavens like a curtain, and set the waters as the rafters of His chambers’ (Psalms 104:2-3). Futher, it says, ‘He makes the winds His messengers and fiery flames His servants’ (Psalms 104:4), and afterward ‘He established the Earth on its foundation so that it will never [עולם ועד] be moved’ (Psalms 104:5). When He completed the pedestal, [the Earth] was strengthened by it, as is said, 'It will never be moved.’ What is its name? ‘Va’ed' [ועד] and the pedestal is ‘Earth' [עולם], thus it is ‘Olam Va’ed' [עולם ועד].”
source: Sefaria Community Translation