i do both at the same time. my friends always say they're going to just eat a lot and get fat, then they'll work out and it'll all turn into muscle. i told them that they're idiots and thats like trying to turn rocks into gold bars... not gonna happen. the body works in weird ways and i find the best thing for me is to just do different intensity cardio workouts to keep a strong heart and also burn a lot of fat. then, i also lift every other day to keep my muscles strong and such. the best thing for gaining muscle is to increase weight while keeping it between 15-20 reps. if 15-20 reps doesnt tire you, then you arent lifting enough weight.
also, i like drinking a lot of ice water... the water keeps my muscles hydrated and resists burning muscle and protein. the ice (or the coldness of the water) keeps my organs nice and cool while i workout and then i burn even more fat to heat back up to 98.6F
in general a healthy balanced diet is the best thing for gaining muscle and losing fat. carbs and fats are necessary, but only at certain times in smaller amounts. protein is always good, especially before and after a workout.