More than 50% of the world’s population lives in cities. Its buildings consume more than a third of the energy and generate 40% of the emissions. This makes cities in general and their buildings in particular priority points of attention for policymakers and utilities. This paper uses population density as a variable to know its influence on energy consumption and emissions produced in buildings. Furthermore, to show its effect more clearly, the influence of the climate was eliminated. The usual energy consumption in buildings is thermal and electrical. The study was carried out at the city level, both per inhabitant and per household. The area actually occupied by the city was considered. The proposed method was applied to the case of Spanish cities with more than 50,000 inhabitants. The results show that the higher the population density, the higher the energy consumption per inhabitant and household in buildings. The consumption of thermal energy is elastic, while that of electrical energy is inelastic, varying more than 100% between extreme groups. Regarding CO2 emissions, the higher the population density, the higher the emissions. Emissions of electrical origin barely vary by 2% and are greater than those of thermal origin. In addition, the proportion of emissions of electrical origin, with respect to the total, decreases with increasing population density from 74% to 55%. This research aims to help policymakers and utilities to take the appropriate measures that favor the use of renewable energies and reduce CO2 emissions.