In the Beginning, God created the heavens and the earth.
In the beginning
Rabbi Yitzchak said: [God] could have begun the Torah only from "This month shall be to you" (Exodus 12:2), which is the first mitzvah (precept) which Israel was commanded. So what is the reason that [God] began with "In the beginning"? Because of [the idea expressed in the verse]: "[God] has declared to His people the power of His works, in order to give them the heritage of the nations" (Psalm 111:6). Thus, should the nations of the world say to Israel: "You are robbers, having conquered the lands of the seven [Canaanite] nations [by force]," [Israel] can say to them: "The whole earth belongs to the Holy Blessed One; He created it and gave it to whomever He saw fit. By His will He gave it to [the Canaanite seven nations], and by His will He took it from them and gave it to us."
In the beginning, [God] created (B'reshit bara)
This verse surely calls out, "Interpret me Midrashically!" As our teachers of blessed memory interpreted it: [God created the world] for the sake of the Torah which is called "the beginning (reshit) of [God's] way" (Proverbs 8:22), and for Israel who were called "the beginning (reshit) of [God's] grain" (Jeremiah 2:3).
However, if you wish to interpret it literally, then interpret it thus: In the beginning of the creation of heaven and earth, when the earth was unformed and void and darkness, God said "Let there be light". The verse does not come to teach the order of creation – to say that these things [heaven and earth] were [created] first – because if this had been what it came to teach, it would have said "First (barishonah) [God] created the heavens," etc. [We cannot understand B'reshit to mean in the beginning], since there is no [instance of] reshit in scripture that is not closely connected to the word after it, e.g.: "In the beginning of Yehoyakim's reign" (Jeremiah 26:1); "the beginning of his kingdom" (Genesis 10:10); "the first fruit [reshit] of your grain" (Deuteronomy 18:4). Likewise here you must interpret B'reshit bara Elohim et hashamayim etc. as if it were written B'reshit b'ro, "In the beginning of [God's] creation of". Similar to it [where the noun in the construct state is followed by a verb rather than a noun] is [the following]: "T'chilat Diber Hashem B'hoshea" (Hosea 1:2), i.e. At the beginning of the Blessed Holy One's speaking to Hosea, God said to Hosea, etc.
But if you say that it comes to teach that these things [heaven and earth] were created first, and that its interpretation is "In the beginning of everything [God] created these" – and indeed you have verses that abridge their language and leave out a word, as in "For it did not close the doors of my womb" (Job 3:10), where it does not specify who is the closer; and as in "... will carry away the riches of Damascus" (Isaiah 8:4), without specifying who will carry it; and as in "If one will plow with cattle" (Amos 6:12), where it does not specify "if a person will plow with cattle"; and as in "Declaring the end from the beginning..." (Isaiah 46:10), where it does not specify "Declaring from the beginning of a thing the end of a thing" – if so, [that the heaven and earth were created first], you must question yourself, because it is written, "And the spirit of God was hovering over the face of the water" (Genesis 1:2), even though the verse had not yet revealed when the creation of water happened. Thus you have learned that the water preceded the earth.
Furthermore, heaven was created from fire and water. So you must admit that the verse does not teach the order of earlier and later [acts of Creation] at all.
And it does not say "Hashem created" [i.e., the Torah refers to the Creator by the name Elohim, signifying strict justice, rather than by the Ineffable 4-letter Name, signifying mercy], because initially [God] thought to create [the world] with the attribute of strict justice. But [God] saw that the world would not last [if governed only with strict justice], so He had the attribute of mercy precede and partner with the attribute of strict justice, and so it is written: "In the day that Hashem God created earth and heaven" (Genesis 2:4) [i.e., the name denoting mercy preceding the one denoting strict justice].
Ibn Ezra 
Talmudic Citations 
- (Taanit 4:3) This passage in the Torah was recited on the first day of each maamad’s turn at Temple service.