A really good knowledge of the book,movie, or character you are going to write about.
A unique idea
Step1
First, make sure you know your subject well. Think of a fanfiction as an opportunity to take the characters and play with them a little bit. There are no rules, only your own creativity will guide you.
Step2
Read some of the other fanfictions in your category. I like fanfiction.net -especially for the Harry Potter series. For the best positive feedback, don't write something that is over-written. For example, in the Harry Potter fanfiction archive, there are a plethora of "time-turner" fictions. Don't even try to write another one. There are too many out there, people get tired of reading the same thing.
Step3
Once you have your unique idea, start writing. Be sure to spell check and format properly, especially when using quotes.
Step4
Fill in with lots of details. The readers don't know what's happening in your mind, the more adjectives you provide, the more they will "see" what you're thinking.
Step5
Before you publish your chapter, be sure to add a disclaimer to the top. It's just common curtesy to acknowledge that you don't own the characters and you are not trying to make money off of your story.
Step6
Make sure to reread your chapter very well. Edit grammatical and spelling errors. Many writers use a "Beta" to edit- that is, a friend or another writer who can take a critical look at your story and give you feedback.
Tips & Warnings
Listen to your readers, they will provide feedback (especially if it is either outstandingly wonderful or really reeks).