Both, defiantly!
See, weight loss is basically calories in vs. calories out. You need to eat fewer calories than you burn. That's where the diet comes in. Healthy food is usually less packed with calories and has more nutritional value. You'll still be able to eat plenty of food and not go hungry, yet still lose weight.
But, when you lose weight, you don't just lose fat. You also lose muscle. That's where the exercise comes in. When you exercise you help your body maintain lean muscle mass, so you burn more fat than muscle. You also burn some calories as a bonus.