There's been a lot of fuss in the book world lately about a self-published book that's become such a sensation that it got picked up by a major publisher in a huge deal and the fact that this book turns out to have been initially written as a fan fiction for a popular book series that the author then "filed off the serial numbers" and published as original fiction. I'm not going to name the book or the series that inspired it because I don't want to get into the specific case, but it has brought out a lot of discussion on the relationship between fan fiction and original fiction.
I think most authors, if they're honest with you, will admit that there is some fan fiction in their history, even if it's purely mental and was never written down. The spark to start writing tends to come from some story that inspired us to the point that we found ourselves imagining further adventures of those characters or perhaps the kind of adventures we might have had in that world. Some people do actually write these stories and share them with others. Others may just imagine these things, and then along the way the story grows and changes until it has nothing in common with the source, and that's when it may get written down.
That's kind of what happened with me. I was a huge Star Wars fan as a kid, and in the long years between Star Wars and The Empire Strikes Back, I imagined all kinds of sequels in my head. In those mental sequels, I added new characters to the cast, and then those characters became more interesting to me than the originals were. I started creating backstory for those characters, and that meant worlds and societies that weren't in the known Star Wars universe (which was very, very limited at that time -- pretty much just Tatooine and the Death Star). Then I realized it was no longer a Star Wars story, and if I wrote it down, it would be a book. I never did finish it, which is probably for the best, as it was something I started coming up with when I was nine, but that was the first story I started writing down and the first time I considered that I wanted to be a writer.
These days, I mostly use my mental fan fiction as a testing ground for story ideas. If I play with an element in the context of someone else's characters and it works, then I can apply it to my characters. If I test it in my head with my characters, then it seems to stick whether or not it works, but if I test it with other characters it doesn't affect the way I see my characters. It's weird, but it works. I may be inspired to use an element or a character trait in a story because of something that intrigues me or frustrates me from some other source. I tend to like the characters who get shoved to the background or passed over, so I may take the things I like about those characters and create that kind of character to make the main character in my story. However, I can't think of any mental fanfic origins behind anything in my Enchanted, Inc. series beyond maybe some character traits. I don't remember anything that really went through my mental fanfic testing ground. I do have some ideas for potential future books that contain elements that started as mental fanfic, but I can't think of any in the published books. The entire series was kind of inspired by the Harry Potter universe, but only in the sense that I read those books and thought that I'd like something like that, but for/about adults. It was never anything that could even remotely have been considered Harry Potter fan fiction. I guess my most successful stuff has been my original stuff, and the mental fanfic stuff is less likely to sell. Go figure.
There are authors who are fairly open about the fanfic origins or inspiration behind their books. Lois McMaster Bujold talks about how Shards of Honor started as a Star Trek fanfic about a Klingon and a Federation officer stranded together on an inhospitable world. They were original characters, not characters who'd appeared in the series, and at that time the Klingon and Federation cultures hadn't been that developed (that came in the Next Generation era), so she extrapolated and ended up creating her own cultures. All she really needed to do was change the names of the cultures and she had an entirely original novel. There was a romance novel published last year that the author openly admitted was inspired by the characters of House and Cuddy on House -- sort of those characters, but what they'd be like in a historical romance setting. She got a nice write-up in TV Guide for it. That doesn't sound too different from that current bestseller, other than the fact that it wasn't originally written and published online as an alternate universe fanfic in which House and Cuddy were in a historical setting before she changed the characters' names and published it as original fiction.
I think some of the controversy around this current book is that it's essentially telling the same story as in the original novel, just in a different setting, as opposed to putting the same characters in a different setting and then telling a different story. And there's probably some outrage over building a fanfic following and then pulling the story, changing the names and making a fortune. I'm really not sure where the ethical lines are. Most authors turn a somewhat blind eye to fanfic based on their books. I know some exists for mine (there's a category for my series on fanfiction.net), but I refuse to even look at it because it creeps me out a little even while it's flattering to know I inspired someone that way (they're my people, so I'm not entirely comfortable with other people making them do things I didn't make them do). I think I would be angry if someone write an Enchanted, Inc. fanfic, changed the characters' names and a few key details of the world, then made a fortune publishing it, mostly because if it made a fortune it would be more successful than the original book. I would generally say, based on my experience, that you'll have more success writing original stories, but recent events (and some other cases) would prove me wrong.