This is a question asked by many and assumed by most. Many people have this image in their mind that they need to burn off the fat first then build the muscle. This is done at a macro and micro level.
The macro level is over time they come to the gym and only do cardio and then after they feel they have burned enough fat, they start to dive into weight training. This is a horrible approach because by simply doing cardio you are eating away at the muscle you do have and restricting yourself of burning more body fat by not building up your muscles. On the micro level (which is what this article is about), people feel they need to get on a treadmill or piece of cardio equipment first, sweat off 10 pounds for about 30 minutes and then go in the weight room and lift. Once again, not the best approach.
Please note that a little 5-10 minute warm up is perfectly fine before lifting, maybe getting the heart rate up to about 50% of your MHR (maximum heart rate), but that is about it.
By getting a little sweat going on BEFORE you lift is ok, your muscles will still have all the energy you will need to work when doing any form of resistance training/weight lifting. Your muscles need that ATP (muscle energy) and it can be burned up and turned into ADP (opposite of muscle energy) which can lead to lack luster workouts. No one has time for that.
So warm up, lift weights and do cardio after lifting weights.
When doing your cardio after you lift weights, heart rate suggestions universally would be 120-140 beats per minute for anywhere from 10 minutes to 30 minutes. To get more specific, getting your heart rate to about 60-70% of your MHR is great for burning fat.
To figure out your MHR (maximum heart rate), simply take the number 220 and minus your age from it. So, if you are 35 years old the formula would be:
220-35 = 185 (MHR) and 70% of that = 129.5 BPM (beats per minute)
So, save your energy for the weights and make sure you are putting your heart rate where it needs to be to save the muscle and burn the fat.