Abstract-Microgrids equipped with small-scale renewableenergy generation systems and energy storage units offer challenging opportunity from a control point of view. In fact, in order to improve resilience and enable islanded mode, microgrid energy management systems must dynamically manage controllable loads by considering not only matching energy generation and consumption, but also thermal comfort of the occupants. Thermal comfort, which is often neglected or oversimplified, plays a major role in dynamic demand response, especially in front of intermittent behavior of the renewable energy sources. This paper presents a novel control algorithm for joint demand response management and thermal comfort optimization in a microgrid composed of a block of buildings, a photovoltaic array, a wind turbine, and an energy storage unit. In order to address the large-scale nature of the problem, the proposed control strategy adopt a two-level supervisory strategy: at the lower level, each building employs a local controller that processes only local measurements; at the upper level, a centralized unit supervises and updates the three controllers with the aim of minimizing the aggregate energy cost and thermal discomfort of the microgrid. Comparisons with alternative strategies reveal that the proposed supervisory strategy efficiently manages the demand response so as to sensibly improve independence of the microgrid with respect to the main grid, and guarantees at the same time thermal comfort of the occupants.