Harry Styles of One Direction inspired wildly popular fan fiction that is now going more mainstream. (Charles Sykes/Charles Sykes/Invision/AP)

It starts with a familiar name, but then takes a turn.

Jay Gatsby actually faked his death, and is now reunited with Daisy. “Scandal’s” Olivia Pope is somehow working on Robert F. Kennedy’s presidential campaign. And a member of the boy band One Direction is falling in love on a college campus — making roughly 250 million online readers swoon.

These are plot twists found in the universe of fan fiction, where authors borrow from another writer’s world, taking characters, places and even real people and putting them in stories all their own. Despite fan fiction’s reputation among old-school publishers for being nothing more than Harry Potter erotica, the online communities have grown to attract all kinds of stories.

And now, that online popularity is shaking up the divide between fan fiction and traditional book publishing. What used to be a disregarded copyright nightmare is a new, youth-friendly approach for publishers.

“Fan fiction has absolutely become part of the fiber of what we publish,” said Jennifer Bergstrom, vice president and publisher of Gallery Books, a division of Simon & Schuster. “This is changing at a time when traditional publishing needs it most.”

Copyright issues can be circumnavigated by changing names and details, polishing up the prose and voila! a book that has a built-in audience is in publishers’ hands. What was once “Twilight” fan fiction is reshaped into the “Gabriel Trilogy” (850,000 copies sold, per the publisher), the “Beautiful Bastard” series (1 million sold) and the infamous “Fifty Shades of Grey” (100 million and counting). And that’s just the start.

On Wednesday, Simon & Schuster took that boy band fan fiction story and published it in ink-on-paper form. The story, called “After,” is a special kind of fan fiction: “real person fiction.” The main characters in “After” are inspired by the five members of One Direction.

Written by 25-year-old Anna Todd, “After” was first published on Wattpad.com, an online writing community where more than 75 million stories live. Copyright concerns are limited because, on that platform, Todd isn’t profiting from her work.

That’s how fan fiction has lived for years: separate from any exchange of cash or contract.

Sites such as Wattpad, Fan­fiction.net and Archive­OfOurOwn.org are overflowing with entries for numerous books, movies, TV shows and plays from Edgar Allan Poe to “The Baby-Sitters Club,” “The Devil Wears Prada” to Peter Rabbit.

The authors of the original works, of course, have mixed reactions. Most notably: J.K. Rowling doesn’t mind if you are creative with her characters, but George R.R. Martin abhors it.

Traditionally, publishers had not been so hot for it, either.

“Fan fiction wasn’t really a word we thought of,” said Shaye Areheart, who formerly oversaw a division at Random House and now runs a publishing course at Columbia University. “It’s very difficult to say how you would get to turn another person’s intellectual property into your own.”

The exception was for authors who had been dead for long enough (70 years, for most) that their work becomes part of the public domain. William Shakespeare and Jane Austen are two of the most common examples.

“The books we love the most are the ones where you close the book and you’re still thinking about those characters,” said Carrie Bebris, author of the “Mr. and Mrs. Darcy Mysteries,” in which the main characters of Austen’s beloved “Pride and Prejudice” solve mysteries together. “We want to be drawn into their lives again, because we didn’t get enough the first time.”

That’s what has made fan fiction popular, even among established authors. English crime writer P.D. James’s Austen-inspired­ book “Death Comes to Pemberley” became a BBC TV movie. (PBS is airing the two-part show Sunday and Nov. 2). Scottish crime writer Val McDermid’s take on “Northanger Abbey” was published in April.

These books don’t typically market themselves as fan fiction. Instead, they’re “inspired by” or “a retelling.”

“The line is not clear between inspiration and fan fiction,” said Ashleigh Gardner, head of content and publishing at Wattpad, where “After” was written. “It’s very much about how the author self-identifies their work.”

“After” author Todd was insistent that Simon & Schuster stay loyal to her fan fiction base. At first, she tried to keep the names of the One Direction band members as her characters’ names.

“I felt like, ‘Are you sure we have to do this? Can’t we just give Harry Styles all the money?’ ” Todd said in an interview.

But before long, Harry became Hardin. Zayn was Zed, Louis was Logan, Niall was Nate and Liam was Landon, and they were just college friends, not bandmates. The only other copyright-concerned change was the tattoo on the stomach of Harry Styles.

“I don’t know a lot of 20-year-old men who have a butterfly tattoo, so we had to change that,” Todd said. Now it’s a tree. A tree that will appear in a book with 80,000 copies on its first print run and in three sequels to “After” that will publish before March. Paramount Pictures has already bought the rights to the movie.

The best-known fan fiction success story is “Fifty Shades of Grey,” which began life as a “Twilight” fan fiction series called “Master of the Universe.”

“If you take away the wrappings of fandom, you have to make sure the story can stand by itself,” said Cindy Hwang, vice president and executive editor at Berkley Books, a division of Penguin Random House.

Hwang is working with three writers who came from fan fiction. One started in the “Twilight” fandom, one in “Harry Potter” and another in “Batman.” While the “Twilight” author was able to transform his story into a three-part bestseller, the others were writing fan fiction in worlds that Hwang said were “too integral” to the story. In other words, you can change the name of Hogwarts, but everyone will still know it is Hogwarts. Hwang had those authors write original books instead.

The only way for fan fiction writers to publish work that keeps the inspiration in plain view is to gain appropriate permissions. The estate of Agatha Christie, for example, recently gave approval to writer Sophie Hannah to create a mystery novel starring Christie’s famous detective Hercule Poirot.

In 2013, Amazon made it possible to make money writing fan fiction through a portal called Kindle Worlds. But the company has permissions to publish submitted content for only 24 “worlds.” And although that list includes big names such as “Pretty Little Liars” and Kurt Vonnegut, 24 fandoms is an incredibly small number compared with the unlimited creations on most fan fiction sites.

Supporters are hoping that the “After” success story clears the way for more than just fan fiction romance writers.

“We’ve been talking about what comes next incessantly” said Bergstrom at Simon & Schuster. “I feel like horror will be it, maybe urban legends. Really any genre could be what comes next.”

And if those fan fiction spinoffs sell like “Fifty Shades of Grey” did?

“Then,” Bergstrom said, “long may they live.”