NOTE: This essay is aimed chiefly at newcomers to fanfiction -- but veteran readers/writers of fanfic may also find certain sections and links to be of interest.
If professional publishing and media are the major leagues, fanfic -- or fan fiction, to use the full phrase -- is sandlot baseball and pickup basketball games down at the Y. Writers of fan fiction aren't in the game for money; they write about their favorite characters from Star Trek or Yu-Gi-Oh or the Harry Potter books because they want more about those characters. And while some fanfic writers go on to publish fiction as pros, others remain by choice in the fanfic sandbox.
On one hand, the stories are a great compliment to the creators of the characters -- it means the original storytellers have fashioned something with which readers or viewers have bonded on a deep personal level. On the other, they open a serious legal can of worms, because copyright and trademark law frown harshly on writers who borrow other people's creative property in ways that may diminish its value.
Before (and After) the Web
In the pre-Internet world, fanfic rarely attracted much attention because it mostly existed "under the radar", practiced by small but lively circles of fans who traded thick manuscripts by US mail and occasionally gathered for weekend-long discussions of their efforts. One might see "mediazines" offered for sale at SF conventions, but the prices barely allowed writers to recover their printing costs, and much of what was being written involved TV series long since cancelled and out of production.
The advent of online message services brought fanfic writers out into the open. CompuServe, Prodigy, and GEnie all developed communities of fanfic writers -- in some cases, representing fans of popular literary universes as well as television and films. And as the Web evolved into its present form, sharing fanfic became as easy as posting text on one's home page.
In the case of media-driven fanfic, the changes have been mostly in form rather than attitude. The corporate owners of such franchises as Buffy and Star Trek officially frown on fanfic, but as a rule they only go after it if it's drawn specifically to their attention, and/or it's outrageous enough to make the franchise look bad (most often, this happens with the more extreme forms of "slash", the subset of fanfic that specializes in same-sex relationships).
Authors of prose fiction have been less tolerant -- and understandably so. The ease of Web publishing (and desktop publishing, for that matter) puts literary fanfic in much more direct competition with its professionally published counterpart. Badly written fanfic can, some argue, more easily trash the image of an author's original work, and better-written material can either steal "market share" from the author's books or take the characters in directions contrary to those their creator had in mind. Even in the pre-Web world, prominent novelists including Chelsea Quinn Yarbro and the late Marion Zimmer Bradley have been involved in serious legal disputes with fanfic writers and editors; in MZB's case, the dispute deep-sixed a substantially completed Darkover novel and spelled the end of a series of shared-world anthologies set in the Darkover universe.
Today's fanfiction writers are becoming stronger advocates for their own work. Most notably, the Organization for Transformative Works -- whose founders include Naomi Novik, author of the immensely popular Temeraire novels -- has launched a number of intriguing projects designed to preserve fans' literary works, encourage academic studies of fanfiction, and put forth arguments asserting the legal and moral rights of fanfic authors.
Principle & Practice
Though the weight of authority to date persuasively argues that fanfiction is a legal no-no, it's often difficult for authors to frame their objections to it as matters of principle. One reason: many pros have written it themselves, though it's rare (but not unknown) for writers to circulate fanfic openly after turning professional.
But there's a more significant explanation. In fact, pro authors practice their own form of fanfic under a different name: "shared world" and "tie-in" fiction. The cabals of writers behind Thieves' World, the Forgotten Realms novels, or the Wild Cards project are engaging in much the same sort of collective creation practiced by fanfic authors writing stories about Buffy Summers or Fox Mulder or Clark Kent. The lines blur even further when one considers examples such as Eric Flint's 1632 universe or Jasper Fforde's The Eyre Affair and its sequels. Flint's Ring of Fire and Grantville Gazette anthologies have welcomed fan authors, and Fforde's Thursday Next novels are strongly reminiscent of the wilder strains of "crossover" fanfic, in which characters from different fictional universes meet and interact.
From a strictly qualitative standpoint, one might reasonably argue that the better distinction isn't between "fanfic" and "profic", but rather between personally created works and collectively created works. This doesn't eliminate all of the legal quagmires associated with fanfic as it's practiced, but it does provide a model that may help both fan and pro writers better understand the creative issues involved, and it helps explain why the ethics of media-based fanfic and fanfic derived from literary sources don't always run in parallel. Media and gaming universes are collaborative by their very nature, while most original (as distinguished from licensed or franchised) prose fiction published by individual authors is -- in specific, at least -- the product of the author's individual imagination.
From a strict legal standpoint, circulating or publishing fanfic is a risky proposition; there's always the chance that someone wearing a Copyright Police badge will show up. Note here that writing fanfic is not, in and of itself, illegal -- it's the distribution that can get one in hot water. [Disclaimer: I Am Not A Lawyer, nor do I play one on Youtube; the foregoing is a layman's opinion and not to be taken as specific legal advice.]
That said, fanfic writers who are (a) writing in a universe that was collaborative to start with, and (b) keeping anything too (porno)graphic out of the hands of minors, are probably not in danger of rousing anyone's serious wrath. At this late date, corporate media-universe owners can't easily rebottle the relevant djinni -- there's just too much fanfic out on the Net already.
Fanfic written in a personally created universe -- that is, spun off from a published author's novel or novels -- is another matter. Unless the author explicitly posts a "Sandbox Open" sign (as indeed, some writers have), the polite (and legally sound) thing to do is to leave that universe alone.
The handful of links below should allow the interested novice to investigate the world of fanfic in somewhat more detail. Be warned that the quality of fanfic (like the quality of "profic") can vary extremely widely, and that some archive sites are more carefully supervised than others. If you go spelunking in any of those I've listed, be prepared for anything -- and remember, you've been warned.