Magic in fiction is the endowment of characters or objects in works of fiction with powers that do not naturally occur in the real world.
Magic often serves as a plot device and has long been a component of fiction, from the days of Homer and Apuleius down through the tales of the Holy Grail and King Arthur, to more contemporary authors such as J. R. R. Tolkien, C. S. Lewis, Ursula K. Le Guin, Robert Jordan, Terry Brooks, J.K. Rowling, Mercedes Lackey, and Derek Landy.
Within a work of fantasy, magic helps to advance the plot, often providing power to the hero of the story and/or power for those who oppose that hero. The use of magic frequently manifests itself in a transformation of the character, if not the transformation of the fictional world.
In order to carry out its function, magic often comes at a price that is equal to its value. (See Fictional magic below.)
Historically, witches such as the Weird Sisters in William Shakespeare's Macbeth, wizards such as Prospero in The Tempest or characters like Doctor Faustus in Christopher Marlowe's play of the same name were widely considered to be real. Contemporary authors tend to treat magic as an imaginary idea, opting to world-build with a blank slate where the laws of reality do not carry as much weight.