Many health and fitness magazines like to splash the wonderful promise of turning fat into muscle on their covers once in a while. They do it for the same reason the tabloids claim Elvis' half-alien offspring is hanging with his old buddies Bigfoot and Jay Leno -- it sells extra copies. Unfortunately, neither is true: You simply cannot transform fat tissue into muscle, and I'm almost certain Jay would choose better company than that.

THE DIFFERENCE

Muscle mass and fat are two different animals: Muscle is active tissue that burns calories around the clock even as you sleep, kind of like an engine running in neutral. When you move around, you burn more calories, just like a car will consume more gas the faster you go. Fat, on the other hand, is just a storage of excess energy. It does nothing but sit there with its sole goal in life to be a spare tire around your waist until you put in the effort to burn it off.
Bodyfat is not particularly useful except as padding against bumps, as insulation to preserve warmth, and as a convenient surface where you can balance a can of beer while watching the game, as frequently demonstrated by my potbellied father. You need some bodyfat to stay healthy of course, but unless you're walking around with razor-sharp abs and sunken, fat-depleted cheeks year-round, you probably have nothing to fear.

LETS GET DOWN TO BUSINESS

Having recognized the difference between the two, let's get down to business: Getting rid of the fat and grow the muscles. Unfortunately, it is almost impossible to achieve both goals at the same time. The reason for this is that in order to maintain an environment in your body that facilitates fat burn, you must deplete yourself of calories. Growth requires extra calories, much like you'd need extra building material to add a room to your house.
In addition, insulin, which is a key component of growing muscle, is the anti-Christ of fat burn and is released whenever you eat carbohydrates (how much and how fast depends entirely on the type of carbs, however.) The conclusion is that you'll have to focus on one thing first and take on the next challenge later on.

TRAIN HEAVY, EAT LOTS OF HEALTHY BODYBUILDING FOOD (PASTA, RICE, CHICKEN, LEAN BEEF, TUNA, OATMEAL ETC.) BUT NO JUNK FOOD, CANDY OR ALCOHOL.
I recommend beginning by trying to pack on the muscle. That means you'll have to eat extra calories, including the extra carbs, and live with the fact that you'll probably gain a few pounds of lard in the process. There's no need to worry about this as long as you keep the increase in body fat under control and avoid ballooning like the Pillsbury Doughboy. Train heavy, eat lots of healthy bodybuilding food (pasta, rice, chicken, lean beef, tuna, oatmeal etc.) but no junk food, candy or alcohol.

DIET

When you've packed on perhaps 5 or 10 pounds of muscle (or whatever your goal was,) switch gears and start the diet. As always, you'll have to keep a daily log of what you eat and carefully adjust your eating patterns so that you eat an average of 500 calories less than you burn each day. Here's where you reap the benefit of having gained the muscle beforehand: Remember the analogy of your muscles being like an engine running in neutral?
Muscle burn calories 24/7, and the more mass you have, the more calories are burned without you even having to lift a finger. This in turn translates to a more lenient diet. In other words, if your added muscle mass boosts your natural metabolism by, say 200 calories per day, that's 200 calories more you can eat and STILL lose body fat! In other words, you'll look better, get to eat more, and will still lose fat at the same rate. How sweet of a deal is that?

KEEP PROTEIN INTAKE UP

As you diet, you want to keep the protein intake up. Also make sure to keep hitting the weights as you did before -- it's your best insurance policy against losing your hard-earned muscle mass. The goal at this point is to slowly but surely shave off the fat without sacrificing mass, so take it easy. No sudden changes in eating habits will improve your situation, only worsen it.
After a few months you should have lost at least 10-15 lbs of fat, and if you played your cards right, you should have kept most of the gains you made prior to the diet. Ta-daa! By taking a little more time and splitting up your two goals, you achieved what you wanted. Had you tried to chase both rabbits simultaneously, you'd been almost guaranteed to fail at least one of the goals.