"A while" and "awhile" have different meanings. "A while" is a noun phrase and means “a period of time.” In contrast, "awhile" is an adverb, and it means “for a time.” This may seem confusing, so keep reading for several helpful examples and tricks.
In a previous Grammar Girl post, I talked about using while to mean although, but another point about "while" can confound people: What is the difference between "a while" and "awhile"?
"A while" describes a time, a noun. The article "a" before "while" is a sure sign that you're dealing with a noun. Notice in the following sentence that you could replace "a while" with another article-noun combination such as "a year":
It's been a while since Squiggly tried marmite.
It’s been a year since Squiggly tried marmite.
Both of those sentences describe a length of time: "a while" is more general and "a year" is more specific, but they’re both a length of time. (Actually, when you use "a year" like that, it’s usually also at least somewhat general because it probably hasn’t been exactly a year since Squiggly tried marmite.)
"Awhile" means "for a time,” and it's an adverb. Notice in the following sentence that you could replace "awhile" with another adverb such as "quietly":
Go play awhile.
Go play quietly.
Finally, just to make it confusing, if you rephrase "Go play awhile" and replace the adverb with a prepositional phrase, you need the noun again because an adverb can't be the object of the preposition.
Go play awhile. (The adverb is modifying the verb.)
Go play for a while. (The article and noun are the object of the preposition.)
The Quick and Dirty Tip is that "awhile" and "a while" both describe a vague length of time, but you use the one-word version when you need an adverb and the two-word version when you need a noun.
To tell the difference, you can test your sentence with other nouns and adverbs. If you can replace "a while" with another article and noun such as "an hour" or "a year," you know you want the two-word version. If you can replace "awhile" with another adverb such as "quietly," "longer," or "briefly," you know you want the one-word version.
NOTE: As is so often the case, English usage isn’t simple. Most sources I checked (Chicago, Garner, AP Stylebook) recommend the guidelines I give in this article, but I found one dissenter: an American Heritage Dictionary usage note says that the noun phrase "a while" can be used adverbially, so that both "Go play awhile" and "Go play a while" are correct. I’m sticking with my advice, but I thought you should know that although it is the most common advice and the safest choice, it’s not universal.
Also, Garner and the Merriam-Webster online dictionary note that the use of "awhile" as the object of a preposition ("Go play for awhile") is increasing. It is still most often called an error, however, and Garner calls it a “stage 1” error in his ranking system, which means it is the least acceptable kind of error.