Calories are the most important thing in weight loss ... yes. Absolutely. Whatever nutrition you get, if you eat more calories than you burn, then yeah, you'll gain weight.
However, within that guideline, it's a good idea to make sure you're eating HEALTHY calories vs. unhealthy calories. I mean you could lose weight eating 1500 calories of cookies per day, but you'd be really malnourished and sick with dull skin, fatigue, brittle hair and nails, etc.
Or you could lose weight eating lean protein (approx 1g per pound of lean body weight), lots of veggies, some fruit, healthy fats (like olive oil, avocado, nuts and seeds, etc.), and finally complex carbs and whole grains.