In the weird, unruly world of fan fiction, anything goes. You can throw Harry Potter and his cohorts into Westeros to fight dragons and zombies, send Bella Swan and Edward Cullen of “Twilight” into space, or write a pornographic version of “Pride and Prejudice.”

The one and perhaps only rule governing fan fiction is that you can’t sell it, unless it’s based on a work that’s already in the public domain. Writers who try to sell fan fiction based on copyrighted works typically get slapped with lawsuits by publishers and production companies.

But now Amazon has found a way to let fan fiction writers and entertainment companies — and of course, Amazon – profit from fan fiction.

This morning, Amazon announced a new digital publishing experiment called “Kindle Worlds,” which will allow people to sell fan fiction through the Kindle platform. For the moment, fan fiction writers can only sell stories based on a few best-selling book series: L.J. Smith’s “Vampire Diaries,” Cecily von Ziegesar’s “Gossip Girl,” and Sara Shepard’s “Pretty Little Liars.” Those series have have already inspired thousands of works of fan fiction, published on sites such as fanfiction.net.

Amazon acquired licenses to the series from Warner Bros. Television Group’s Alloy Entertainment division, and says it will announce more licenses soon. The company will pay royalties to both the copyright holders, like Alloy, and the authors, but Amazon will retain all rights to the fan fiction, including global publication rights, for the copyright term. Authors will get 35% of net revenue.

Some fan fiction writers will no doubt jump at the chance to charge for their work. Several fan fiction writers, such as Cassandra Clare, author of the best-selling “Mortal Instruments” series, who used to write Harry Potter fan fiction, and E.L. James, author of “Fifty Shades of Grey,” which began as Twilight fan fiction, have gone on to become blockbuster authors themselves.

But not everyone will go for it. Fan fiction writers are an anarchic and irreverent bunch – witness the bizarre subgenre of Harry Potter fan fiction called “mpreg,” in which Harry or another male character becomes pregnant. Amazon’s press release makes it clear that there will be some limits to what authors can do to beloved characters. The release says that Amazon will work with licensors like Alloy “to establish content guidelines that balance flexibility and openness for writers with what’s reasonable for the franchise.”