Short answer
Six. The Qur'an says seven times that God (﷾) created the heavens and the earth in six days. Some critics add up Surat Fussilat 41:9-12 and get eight: two days for the earth, four for its provision, and two for the heavens. But the four days of verse 10 are a running total. They include the two days of verse 9 and do not come after them. A builder may say the walls took two days and the whole house four. He does not mean six days in all. Ibn Abbas, a Companion of the Prophet (ﷺ), gave the same total: four days for the earth and two for the heavens. The commentators (scholars who explain the Qur'an) after him agree. Four and two make six, the same total the Qur'an gives everywhere else. So Islam holds that the Qur'an gives one number, six.
Full explanation
Six days, every time
Seven times the Qur'an gives the total for the creation of the heavens and the earth, and seven times it is six. It never gives any other number. A reading of one passage that turns six into eight is therefore a reading the Book itself rules out.
“Your Guardian-Lord is Allah, Who created the heavens and the earth in six days, and is firmly established on the throne (of authority): He draweth the night as a veil o'er the day, each seeking the other in rapid succession: He created the sun, the moon, and the stars, (all) governed by laws under His command. Is it not His to create and to govern? Blessed be Allah, the Cherisher and Sustainer of the worlds!”
“Verily your Lord is Allah, who created the heavens and the earth in six days, and is firmly established on the throne (of authority), regulating and governing all things. No intercessor (can plead with Him) except after His leave (hath been obtained). This is Allah your Lord; Him therefore serve ye: will ye not receive admonition?”
“He it is Who created the heavens and the earth in six Days - and His Throne was over the waters - that He might try you, which of you is best in conduct. But if thou wert to say to them, "Ye shall indeed be raised up after death", the Unbelievers would be sure to say, "This is nothing but obvious sorcery!"”
“He Who created the heavens and the earth and all that is between, in six days, and is firmly established on the Throne (of Authority): Allah Most Gracious: ask thou, then, about Him of any acquainted (with such things).”
“It is Allah Who has created the heavens and the earth, and all between them, in six Days, and is firmly established on the Throne (of Authority): ye have none, besides Him, to protect or intercede (for you): will ye not then receive admonition?”
“We created the heavens and the earth and all between them in Six Days, nor did any sense of weariness touch Us.”
“He it is Who created the heavens and the earth in Six Days, and is moreover firmly established on the Throne (of Authority). He knows what enters within the earth and what comes forth out of it, what comes down from heaven and what mounts up to it. And He is with you wheresoever ye may be. And Allah sees well all that ye do.”
How the days in Fussilat are counted
Verse 9 says the earth was created in two days. Verse 10 then describes the mountains, the blessing and the provision of the earth. It closes the account of the earth with "in four Days" (fi arba'ati ayyam). That phrase gives the total for the whole work on the earth, the first two days included. It works like "the house took four days", which includes the two days spent on the walls. Verse 12 adds two days for the seven heavens. Four and two make six.
“Say: Is it that ye deny Him Who created the earth in two Days? And do ye join equals with Him? He is the Lord of (all) the Worlds. He set on the (earth), mountains standing firm, high above it, and bestowed blessings on the earth, and measure therein all things to give them nourishment in due proportion, in four Days, in accordance with (the needs of) those who seek (Sustenance). Moreover He comprehended in His design the sky, and it had been (as) smoke: He said to it and to the earth: "Come ye together, willingly or unwillingly." They said: "We do come (together), in willing obedience." So He completed them as seven firmaments in two Days, and He assigned to each heaven its duty and command. And We adorned the lower heaven with lights, and (provided it) with guard. Such is the Decree of (Him) the Exalted in Might, Full of Knowledge.”
Verse 9: two days
The earth is created in two days.
Verse 10: four days in all
The mountains, the blessing and the provision complete the earth in four days, the first two included.
Verse 12: two more days
The seven heavens are completed in two days.
Total: six days
Four and two make six, the same total the Qur'an gives seven times.
Read this way from the start
This is not a modern repair. A man once brought this passage to Ibn Abbas, the Prophet's (ﷺ) cousin and Companion, among several verses that confused him. In his answer Ibn Abbas said that the earth and all in it were made in four days and the heavens in two. Al-Bukhari, the hadith collector, records his answer in the Tafsir chapter of his Sahih. That chapter explains the Qur'an. He gives the answer without its full chain of narrators. Ibn Kathir, a Qur'an commentator writing in the fourteenth century, gives the same total.
Ibn Kathir counts the days of 41:9-12 as a running total. The earth was made in two days and its mountains, blessing and provision in two more, which together with the first two make the four days of verse 10. The seven heavens were then completed in two further days. He quotes the Companion Ibn Abbas, as recorded by al-Bukhari, answering a man who had brought this passage to him among others that confused him: the earth and all that is in it in four days, and the heavens in two.
“Say: Is it that ye deny Him Who created the earth in two Days? And do ye join equals with Him? He is the Lord of (all) the Worlds. He set on the (earth), mountains standing firm, high above it, and bestowed blessings on the earth, and measure therein all things to give them nourishment in due proportion, in four Days, in accordance with (the needs of) those who seek (Sustenance). Moreover He comprehended in His design the sky, and it had been (as) smoke: He said to it and to the earth: "Come ye together, willingly or unwillingly." They said: "We do come (together), in willing obedience." So He completed them as seven firmaments in two Days, and He assigned to each heaven its duty and command. And We adorned the lower heaven with lights, and (provided it) with guard. Such is the Decree of (Him) the Exalted in Might, Full of Knowledge.”
The test the Qur'an sets itself
The Qur'an invites its readers to look for contradictions, and says that a book from anyone but God (﷾) would contain many. The six-or-eight objection is a question of how the passage counts days. It is not two statements that cannot both be true. Once the counting is read correctly, nothing is left of it.
“Do they not consider the Qur'an (with care)? Had it been from other Than Allah, they would surely have found therein Much discrepancy.”
The objection, answered
Qur'an 41:9-12 — Surat Fussilat (Explained in detail), verses 9-12
“Say: Is it that ye deny Him Who created the earth in two Days? And do ye join equals with Him? He is the Lord of (all) the Worlds. He set on the (earth), mountains standing firm, high above it, and bestowed blessings on the earth, and measure therein all things to give them nourishment in due proportion, in four Days, in accordance with (the needs of) those who seek (Sustenance). Moreover He comprehended in His design the sky, and it had been (as) smoke: He said to it and to the earth: "Come ye together, willingly or unwillingly." They said: "We do come (together), in willing obedience." So He completed them as seven firmaments in two Days, and He assigned to each heaven its duty and command. And We adorned the lower heaven with lights, and (provided it) with guard. Such is the Decree of (Him) the Exalted in Might, Full of Knowledge.”
Cited for
The passage gives two days for the earth, four more for its mountains and provision, and two for the heavens. That is eight days, which contradicts the six days stated elsewhere in the Qur'an.
The response
The four days of verse 10 are the total for the earth, and they include the two days of verse 9. Ibn Abbas, who was asked about this passage, counted four days for the earth and two for the heavens. The commentators followed him. Adding the two days again counts them twice.
Where it lands — The passage adds up to six days, the same total the Qur'an gives in seven other verses.
Perspectives
The Islamic perspective
God (﷾) created the heavens and the earth in six days, as the Qur'an states seven times. Surat Fussilat gives the same six days in more detail. Four are for the earth, which include the first two, and two are for the heavens.
In seven separate verses the Qur'an gives six days as the total for creating the heavens and the earth. It never gives another total.
In 41:10 the phrase "in four days" gives the total for all the work on the earth. That includes the two days of 41:9, so the passage adds up to six.
Ibn Abbas, a Companion of the Prophet (ﷺ), counted the days of 41:9-12 as four for the earth and two for the heavens. So did Ibn Kathir after him.
The Qur'an says that a book from other than God (﷾) would contain many contradictions. This objection does not produce one.