George M. breaks it down:
We can recognize it when we see it: witches and wizards casting spells at one another with their great yew staffs, great dragons loosely based on dinosaur renderings, but mostly constructed from pure imagination, ravaging nearby villages with terrific flames, having no explanation for their actions other than that they can. These are defining characteristics of the fantasy genre.
The average person can read a book about wizards and magic and tell you that he or she is reading a fantasy novel (even if the section in the book store didn't already give that away). It is much harder, however, for that person to explain why that novel is classified as "fantasy" and not something else, like mythological fiction or science fiction. In order to explain why this is, we must first look at what fantasy is.
This is my attempt to sum up what fantasy is in a neat sciencey way: "fantasy is the opposite of what could ever be." That’s probably what Emily Dickinson would say if you asked her. You can't, though; she’s dead. She loved to squeeze a book's worth of meaning into a two-stanza poem. The only way to truly appreciate the meaning of that vague, almost cryptic statement is to crank the handle of this fantasy Jack-in-the-box and stand back. Here we go...
Fantasy is wholly subjective of the author's reality and the technology available at the time. For example, an 18th century author could write a novel about horseless carriages and weapons that use light to injure an enemy and this novel would easily fall into the genre of fantasy. A person could pick up and read that same novel today and would be able to classify it as merely a work of fiction. The reason being is because those things are actually in use today, not just concepts (although using a laser as a weapon today would be difficult, as the really powerful ones are still bulky and stationary). What a difference 300 years can make!
The reason why the author classified his novel as "fantasy" was because mechanical, horseless carriages and light-based weapons were the farthest things from his present reality. They were "the opposite of what could ever be" for him. He simply could not fathom a reality where these things existed, so made the decision to place his novel in the same category that houses tales about magic artifacts and unknown worlds. Although the potential for these things existed at the time, the author was ignorant to that potential, and only used his imagination as reference. This 18th century author who exists solely in my example could have classified his novel as "sci-fi," and you'll see why this is momentarily.
J.R.R. Tolkien's The Hobbit falls under the domain of fantasy because there is no record of our past and no evidence of our future depicting an Earth where dragons, dwarves, and goblins could have existed or could exist. Unfortunately, a world where Gandalf exists is not in our foreseeable future, and because of this The Hobbit must be classified as a work of fantasy.
So far we can conclude that in order for a piece of literature to be considered "fantasy," it cannot have a basis in reality. Although this statement seems quite obvious, there is much more to it than that. How many of the elements of the novel that are based in reality and what these elements consist of play a defining role in determining whether a work is considered fantasy or science fiction or some other genre.
If an author writes a story about a world that uses more sophisticated technology than the time in which he is writing in (all my examples are male--sorry, ladies), and the author tries to give a scientific explanation as to how this technology works, then this work can be classified as "science fiction." Although the world itself that the author is describing might not be our world in the foreseeable future, the technology he is describing might. If the author is writing a book about a "green planet" where all the energy we use is derived from fusion reactors, even though that world is obviously not our present one, fusion technology does exist, and so a basis in science fiction can be justified. The Hobbit is classified as "fantasy" as opposed to "sci-fi," because Tolkien did not make any attempt to scientifically explain how Gandalf can shoot lightning out of his staff. However, I don’t think Tolkien ever planned to. The author has to attempt to explain why things are the way they are for his work to be considered "sci-fi."
If a different author wrote a piece of literature in the year 200 B.C and wrote about Zeus and Athena tormenting a mortal man because he angered them in some way, a person who has read this far (and has never heard of mythology before) might guess that this work would be considered "fantasy," but this person would be wrong, although his or her guess makes perfect logical sense. This particular piece of literature would be considered "fantasy" if figures like Zeus and Athena did not have an actual basis in reality. Technically speaking, they do not. They never existed. Well, that is not exactly true, either. Zeus and Athena existed in the minds of the audience the author was writing for. They believed that these gods were real, and because it was a commonly held belief and a commonly accepted truth, this work cannot be considered "fantasy" and must be a work of mythology, a genre of literature that uses supernatural figures to explain real events.
Even though we know that the Greek gods were never real, we cannot reclassify the example story described in the beginning of the last paragraph as "fantasy." The reason being is that even though we know that the Greek gods never existed (although we cannot say that with total certainty), people once believed that they did. This work had a basis in reality, even though it is not the present one. Due to the subjective nature of reality and once-believed social truths, the work of literature that was written in 200 B.C. must be classified as a work of "mythology": things that people once believed were true, but now are not.
We can conclude that for a literary work to be considered a work of fantasy, it cannot have a substantial basis in our present reality. If an author tries to give scientific explanations as to why his world is the way it is, then this work is no longer considered "fantasy," and must be considered "science fiction." If an author writes about elements that he and everyone of the reality at the time of publication believe to be true, then that particular literary work is considered "mythology," not "fantasy." Hence, what exactly defines a piece of literature as "fantasy" is always changing because our reality is always changing. The perception of truth plays such a monumental role in defining fantasy that a truly concrete definition can't be achieved. In order to know that what you are writing will be considered "fantasy" (at least in your present time), just write about what you think can never happen. Because to write in the genre of fantasy is to believe that the impossible will remain impossible.
Tolkien, J.R.R. The Hobbit, Revised Ed. New York: Random House, 1997. Print.