Over on Gamasutra, attorney Mona Ibrahim has provided a handy guide on how to go about making a fan game, get it finished, and not end up with a nasty letter from Nintendo or George Lucas for your troubles.
The best plan of action is to "rely on unprotected game elements, mechanics and processes" and ask the IP owner for permission before commencing work. If those don't work, you can always take what inspired you from somebody else's game and use it as a foundation to build your own game on.
Budding modders and developers note, however, Ibrahim's advice is followed by a big 'THE INFORMATION IN THIS ARTICLE IS FOR EDUCATIONAL PURPOSES ONLY. The content of this article is not legal advice" disclaimer, so, yeah, tread lightly.
To read the whole thing in-depth, hit up Gamasutra below.
Analysis: Clone Games & Fan Games — Legal Issues [Gamasutra]