You can't really properly gain muscle mass and NOT gain fat at the same time. This is why body builders alternate "bulking" and "cutting" phases in their workout/diet plans. Usually "bulking" means lots of calories, protein favored, above BMR and lots of lifting heavy things. Cardio is avoided like the plague in the bulking phase as it actually is counterproductive.
Then, the cutting phase. Lifting is continued, though it may be dialed back a little, calories are usually around BMR, and protein is maintenance level, not more. This is when you typically do the cardio a bit to help the loss.
Bulking is for building muscle mass. Cutting is for increasing muscle definition.