Fantasy is a genre of fiction set in a fictional universe, often, but not always, without any locations, events, or people referencing the real world. Its roots are in oral traditions, which then developed into literature and drama. From the twentieth century it has expanded further into various media, including film, television, graphic novels and video games.
Most fantasy uses magic or other supernatural elements as a main plot element, theme, or setting. Magic and magical creatures are common in many of these worlds. Fantasy is a subgenre of speculative fiction and is distinguished from the genres of science fiction and horror by the absence of scientific or macabre themes respectively, though these genres overlap.
In popular culture, the fantasy genre is predominantly of the medievalist form. In its broadest sense, however, fantasy comprises works by many writers, artists, filmmakers, and musicians from ancient myths and legends to many recent and popular works.
Fantasy is studied in a number of disciplines including English and other language studies, cultural studies, comparative literature, history and medieval studies. Work in this area ranges widely from the structuralist theory of Tzvetan Todorov, which emphasizes the fantastic as a liminal space, to work on the connections (political, historical and literary) between medievalism and popular culture.
The identifying trait of fantasy is the author's reliance on imagination to create narrative elements that do not have to rely on history or nature to be coherent. This differs from realistic fiction in that whereas realistic fiction has to attend to the history and natural laws of reality, fantasy does not. An author applies his or her imagination to come up with characters, plots, and settings that are impossible in reality. Many fantasy authors use real-world folklore and mythology as inspiration; and although for many the defining characteristic of the fantasy genre is the inclusion of supernatural elements, such as magic, this does not have to be the case. For instance, a narrative that takes place in an imagined town in the northeastern United States could be considered realistic fiction as long as the plot and characters are consistent with the history of region and the natural characteristics that someone who has been to the northeastern United States expects; when, however, the narrative takes place in an imagined town, on an imagined continent, with an imagined history and an imagined ecosystem, the work becomes fantasy with or without supernatural elements.
Fantasy has often been compared with science fiction and horror because they are the major categories of speculative fiction. Fantasy is distinguished from science fiction by the plausibility of the narrative elements. A science fiction narrative is unlikely, though seeming possible through logical scientific or technological extrapolation, whereas fantasy narratives do not need to be scientifically possible. The imagined elements of fantasy do not need a scientific explanation to be narratively functional. Authors have to rely on the readers' suspension of disbelief, an acceptance of the unbelievable or impossible for the sake of enjoyment, in order to write effective fantasies. Despite both genres' heavy reliance on the supernatural, fantasy and horror are distinguishable. Horror primarily evokes fear through the protagonists' weaknesses or inability to deal with the antagonists. 
Elements of the supernatural and the fantastic were an element of literature from its beginning. Fantasy elements occur throughout the ancient Akkadian Epic of Gilgamesh. Folk tales with fantastic elements intended for adults were a major genre of ancient Greek literature.  The comedies of Aristophanes are filled with fantastic elements,  particularly his play The Birds,  in which an Athenian man builds a city in the clouds with the birds and challenges Zeus's authority.  Ovid's Metamorphoses and Apuleius's The Golden Ass are both works that influenced the development of the fantasy genre  by taking mythic elements and weaving them into personal accounts.  Both works involve complex narratives in which humans beings are transformed into animals or inanimate objects. 
Platonic teachings and early Christian theology are major influences on the modern fantasy genre.  Plato used allegories to convey many of his teachings,  and early Christian writers interpreted both the Old and New Testaments as employing parables to relay spiritual truths.  This ability to find meaning in a story that is not literally true became the foundation that allowed the modern fantasy genre to develop. 
There are many works where the boundary between fantasy and other works is not clear; the question of whether the writers believed in the possibilities of the marvels in A Midsummer Night's Dream or Sir Gawain and the Green Knight makes it difficult to distinguish when fantasy, in its modern sense, first began.
Although pre-dated by John Ruskin's The King of the Golden River (1841), the history of modern fantasy literature is usually said to begin with George MacDonald, the Scottish author of such novels as The Princess and the Goblin and Phantastes (1858), the latter of which is widely considered to be the first fantasy novel ever written for adults. MacDonald was a major influence on both J. R. R. Tolkien and C. S. Lewis. The other major fantasy author of this era was William Morris, a popular English poet who wrote several novels in the latter part of the century, including The Well at the World's End.
Despite MacDonald's future influence with At the Back of the North Wind (1871), Morris's popularity with his contemporaries, and H. G. Wells's The Wonderful Visit (1895), it was not until the 20th century that fantasy fiction began to reach a large audience. Lord Dunsany established the genre's popularity in both the novel and the short story form. Many popular mainstream authors also began to write fantasy at this time, including H. Rider Haggard, Rudyard Kipling, and Edgar Rice Burroughs. These authors, along with Abraham Merritt, established what was known as the "lost world" subgenre, which was the most popular form of fantasy in the early decades of the 20th century, although several classic children's fantasies, such as Peter Pan and The Wonderful Wizard of Oz, were also published around this time.
Indeed, juvenile fantasy was considered more acceptable than fantasy intended for adults, with the effect that writers who wished to write fantasy had to fit their work in a work for children. Nathaniel Hawthorne wrote fantasy in A Wonder-Book for Girls and Boys, intended for children, though works for adults only verged on fantasy. For many years, this and successes such as Alice's Adventures in Wonderland (1865), created the circular effect that all fantasy works, even the later The Lord of the Rings, were therefore classified as children's literature.
Political and social trends can affect a society's reception towards fantasy. In the early 20th century, the New Culture Movement's enthusiasm for Westernization and science in China compelled them to condemn the fantastical shenmo genre of traditional Chinese literature. The spells and magical creatures of these novels were viewed as superstitious and backward, products of a feudal society hindering the modernization of China. Stories of the supernatural continued to be denounced once the Communists rose to power, and mainland China experienced a revival in fantasy only after the Cultural Revolution had ended.
Fantasy was a staple genre of pulp magazines published in the West. In 1923, the first all-fantasy fiction magazine, Weird Tales, was published. Many other similar magazines eventually followed, most noticeably The Magazine of Fantasy and Science Fiction; when it was founded in 1949, the pulp magazine format was at the height of its popularity, and the magazine was instrumental in bringing fantasy fiction to a wide audience in both the U.S. and Britain. Such magazines were also instrumental in the rise of science fiction, and it was at this time the two genres began to be associated with each other.
By 1950, " sword and sorcery " fiction had begun to find a wide audience, with the success of Robert E. Howard's Conan the Barbarian and Fritz Leiber's Fafhrd and the Gray Mouser stories. However, it was the advent of high fantasy, and most of all J. R. R. Tolkien's The Hobbit and The Lord of the Rings, which reached new heights of popularity in the late 1960s, that allowed fantasy to truly enter the mainstream. Several other series, such as C. S. Lewis's Chronicles of Narnia and Ursula K. Le Guin's Earthsea books, helped cement the genre's popularity.
The popularity of the fantasy genre has continued to increase in the 21st century, as evidenced by the best-selling status of J. K. Rowling's Harry Potter series or of George R. R. Martin's Song of Ice and Fire sequence.
Several fantasy film adaptations have achieved blockbuster status, most notably The Lord of the Rings film trilogy directed by Peter Jackson, and the Harry Potter films, two of the highest-grossing film series in cinematic history. Meanwhile, David Benioff and D. B. Weiss would go on to produce the television drama series Game of Thrones for HBO, which has gone on to achieve unprecedented success for the fantasy genre on television.
Fantasy role-playing games cross several different media. Dungeons & Dragons was the first tabletop role-playing game and remains the most successful and influential.   The science fantasy role-playing game series Final Fantasy has been an icon of the role-playing video game genre (as of 2012 still among the top ten best-selling video game franchises). The first collectible card game, Magic: The Gathering, has a fantasy theme and is similarly dominant in the industry. 
By theme (subgenres)
Fantasy encompasses numerous subgenres characterized by particular themes or settings, or by an overlap with other literary genres or forms of speculative fiction. They include the following:
- Bangsian fantasy, interactions with famous historical figures in the afterlife, named for John Kendrick Bangs
- Comic fantasy, humorous in tone
- Contemporary fantasy, set in the real world but involving magic or other supernatural elements
- Dark fantasy, including elements of horror fiction
- Epic fantasy, see "high fantasy" below
- Fables, stories with nonhuman characters, leading to "morals" or lessons
- Fairy tales themselves, as well as fairytale fantasy, which draws on fairy tale themes
- Fantastic poetry, poetry with a fantastic theme
- Fantastique, French literary genre involving supernatural elements
- Fantasy of manners, or mannerpunk, focusing on matters of social standing in the way of a comedy of manners
- Gaslamp fantasy, stories in a Victorian or Edwardian setting, influenced by gothic fiction
- Gods and demons fiction (shenmo ), involving the gods and monsters of Chinese mythology
- " Grimdark " fiction, a somewhat tongue-in-cheek label for fiction with an especially violent tone or dystopian themes
- Hard fantasy, whose supernatural aspects are intended to be internally consistent and explainable, named in analogy to hard science fiction
- Heroic fantasy, concerned with the tales of heroes in imaginary lands
- High fantasy or epic fantasy, characterized by a plot and themes of epic scale
- Historical fantasy, historical fiction with fantasy elements
- Juvenile fantasy, children's literature with fantasy elements
- Low fantasy, characterized by few or non-intrusive supernatural elements, in contrast to high fantasy
- Magic realism, a genre of literary fiction incorporating minor supernatural elements
- Magical girl fantasy, involving young girls with magical powers, mainly in Japanese anime and manga
- Paranormal romance, romantic fiction with fantasy elements
- Romantic fantasy, focusing on romantic relationships
- Sword and sorcery, adventures of sword-wielding heroes, generally more limited in scope than epic fantasy
- Urban fantasy, set in a city
- Weird fiction, macabre and unsettling stories from before the terms "fantasy" and "horror" were widely used; see also the more modern forms of slipstream fiction and the New Weird
- Wuxia, Chinese martial-arts fiction often incorporating fantasy elements
By the function of the fantastic in the narrative
In her 2008 book Rhetorics of Fantasy, Farah Mendlesohn proposes the following taxonomy of fantasy, as "determined by the means by which the fantastic enters the narrated world", while noting that there are fantasies that fit neither pattern:
In a "portal-quest fantasy" or "portal fantasy", a fantastical world is entered through a portal, behind which the fantastic elements of the story remain contained. These tend to be quest -type narratives, whose main challenge is navigating the fantastical world. Well-known portal fantasies include C. S. Lewis's novel The Lion, the Witch and the Wardrobe (1950) and L. Frank Baum's novel The Wonderful Wizard of Oz (1900).
The "immersive fantasy" lets the reader perceive the fantastical world through the eyes and ears of the protagonist, without an explanatory narrative. The fictional world is seen as complete, and its fantastic elements are not questioned within the context of the story. If successfully done, this narrative mode "consciously negates the sense of wonder " often associated with speculative fiction. But, according to Mendlesohn, "a sufficiently effective immersive fantasy may be indistinguishable from science fiction" because, once assumed, the fantastic "acquires a scientific cohesion all of its own", which has led to disputes about how to classify novels such as Mary Gentle's Ash (2000) and China Miéville's Perdido Street Station (2000).
In an "intrusion fantasy", the fantastic intrudes on reality (in contrast to portal fantasies, where the opposite happens), and the protagonists' engagement with that intrusion drives the story. Intrusion fantasies are normally realist in style, because they assume the normal world as their base, and rely heavily on explanation and description. Immersive and portal fantasies may themselves host intrusions. Classic intrusion fantasies include Dracula by Bram Stoker (1897) and the works of H. P. Lovecraft.
"Liminal fantasy", finally, is a relatively rare mode where the fantastic enters a world that appears to be our own, but this is not perceived as intrusive but rather as normal by the protagonists, and this disconcerts and estranges the reader. Such fantasies adopt an ironic, blasé tone, as opposed to the straight-faced mimesis of most other fantasy. Examples include Joan Aiken's stories about the Armitage family, who are amazed that unicorns appear on their lawn on a Tuesday, rather than on a Monday.
Professionals such as publishers, editors, authors, artists, and scholars within the fantasy genre get together yearly at the World Fantasy Convention. The World Fantasy Awards are presented at the convention. The first WFC was held in 1975 and it has occurred every year since. The convention is held at a different city each year.
Additionally, many science fiction conventions, such as Florida's FX Show and MegaCon, cater to fantasy and horror fans. Anime conventions, such as Ohayocon or Anime Expo frequently feature showings of fantasy, science fantasy, and dark fantasy series and films, such as Majutsushi Orphen (fantasy), Sailor Moon (urban fantasy), Berserk (dark fantasy), and Spirited Away (fantasy). Many science fiction/fantasy and anime conventions also strongly feature or cater to one or more of the several subcultures within the main subcultures, including the cosplay subculture (in which people make or wear costumes based on existing or self-created characters, sometimes also acting out skits or plays as well), the fan fiction subculture, and the fan video or AMV subculture, as well as the large internet subculture devoted to reading and writing prose fiction or doujinshi in or related to those genres.
According to 2013 statistics by the fantasy publisher Tor Books, men outnumber women by 67% to 33% among writers of historical, epic or high fantasy. But among writers of urban fantasy or paranormal romance, 57% are women and 43% are men.