In the beginning, Elokim created the heavens and the earth... (Gen. 1:1)
The Torah begins with the letter beit [whose numerical value is 2] to inform us that two things are called "Beginning" - namely the heavens and the earth. For just as the heavens were created "first," so too was the earth!
We read in the Talmud (Chagiga 12a; according to Maharsha):
Beit Shamai maintains that the heavens were created first, and only afterwards the earth, as it is written, "In the beginning Elokim created the heavens [first] and [then] the earth" (Gen. 1:1). Beit Hillel maintains that the earth was created first, and only afterwards the heavens, as it is written, "On the day that Lord G‑d made earth and heaven" (Gen. 2:4).
Beit Hillel challenged Beit Shamai: "According to your reasoning, a person [who wants to build a two-story house] would first have to build the upper story, and only then complete the ground floor. [That is impossible for a man to do; and it is even unlikely that G‑d would switch the natural order of things in such a way.] This is the meaning of the verse, 'Did He build His upper chambers in the heavens, and [only then] establish His stairway on the earth?!' (Amos 9:6)." [We must therefore say that the earth was established first, and only then the heavens.] Heaven and earth…were created together like a pot and its cover…
Beit Shamai retorted to Beit Hillel: "According to your reasoning, a person makes a footstool first, and then a chair upon which to sit. The following verse [indicates otherwise], 'Thus says G‑d: The heavens are My throne and the earth is My footstool'. (Isaiah 66:1)." [We must therefore say that the heavens preceded the earth.]
The Rabbis maintain that they [the heavens and earth] were created together, at the same time, as it is written, "My hand has also founded the earth; and My right hand has stretched forth the heavens. I [G‑d] call to them, and they stand up together". (Isaiah 48:13)
The Midrash (Bereishit Rabba 1:15) adds:
Rabbi Yehuda bar Ilai said: "Another verse helps prove Beit Hillel's position, 'Long ago, You founded the earth', and afterwards, 'the heavens are the work of Your hands' (Psalms 102:26)".
Rabbi Yochanan said in the name of the sages: "In terms of [the entirety of] Creation, it is clear that the heavens preceded the earth. In terms of [bringing the Creation to] completion, it is clear that the earth preceded the heavens.
Rabbi Shimon bar Yochai said: I am surprised that those Fathers of the world, Shamai and Hillel, argued over the [order of the] Creation of heaven and earth. Rather, in my opinion, they were created together like a pot and its cover, as the verse attests, "I [G‑d] call to them, and they stand up together". (Isaiah 48:13)
Rabbi Chaim Vital now begins to explain the above "dispute":
In the first verse of the Torah, the heavens are mentioned first, while the earth is mentioned second. The same is true of Gen. 2:4, where the first half of the verse states, "These are the chronicles of the heavens and the earth when they were created."
Nevertheless, in the second half of that same verse, the order is reversed, and reads, "On the day that G‑d Elokim made earth and heaven."
Similarly, it is written in Isaiah, "My hand has also founded the earth; and My right hand has stretched forth the heavens" (Isaiah 48:13). Interestingly, the verse begins by saying "My hand has also founded". This seems to indicate that the heavens were created first. Afterwards, however, when it says "and My right hand has stretched forth the heavens", the prefix "and" of "and My right hand" seems to indicate that this was done after something else, namely, after His left hand founded the earth. Only after this did His right hand stretch forth the heavens.
In addition to there being numerous verses that seem to contradict each other; Isaiah 48:13 thus seems to contain its own internal contradiction. In the universe of Beriya, the heavens preceded the earth…
[In order to understand this properly, it is necessary to introduce an important distinction:] In the universe of Beriya, the heavens preceded the earth. For in that dimension, holiness and spirituality dominate. In the lower world of Asiya, on the other hand, the earth preceded the heavens.
Beriya is the causal reality that lies above and behind the physical world that we perceive with our senses. It corresponds to the 1st day of Creation when everything was still in potential. Asiya ["Action" "Completion"] is usually identified with the material dimension that is the end-product of the entire creation process. By introducing this distinction, the Ari has shown that Beit Shamai and Beit Hillel aren't really arguing - and teaches us to look deeper into the layers of reality that lie behind and above our sense perceived world. In Asiya, physicality is more dominant…
This is the meaning of the statement [in the Midrash above by Rabbi Yochanan]: "In terms of [the entirety of] Creation, it is clear that the heavens preceded the earth. In terms of [bringing the Creation to] completion, it is clear that the earth preceded the heavens." In Asiya, physicality is more dominant, for the entire intention of bringing the dimension of Asiya into existence was to materialize [i.e. give form to] all [the subtle levels that preceded it]. The verse [Gen. 2:4] indicates this by placing "earth" before "heaven".
Accordingly, the first half of Gen. 2:4, "These are the chronicles of the heavens and the earth when they were created," alludes to the dimension of Beriya [the world of Creation]. The second half, "On the day that G‑d Elokim made earth and heaven," alludes to the dimension of Asiya [the world of Action or Making].
Similarly, in Isaiah 48:13, the first half of the verse refers to Beriya, in which heaven preceded earth. This explains the addition of the word "also" in the first part of the verse, indicating that something (i.e. heaven) preceded the founding of the earth, specifically in Beriya.
Conversely, the second half of the verse refers to Asiya in which earth preceded heaven. This explains the prefix "and" of "and My right hand…" It indicates that, in Asiya, something else (i.e. the founding of the earth) preceded the stretching forth of the heavens.
Translated and adapted by Avraham Sutton from Likutei Torah, "Chumash Ari" Bereishit, p. 6