This paper presents a two-level hierarchical energy management system (EMS) for microgrid operation that is based on a robust model predictive control (MPC) strategy. This EMS focuses on minimizing the cost of the energy drawn from the main grid and increasing self-consumption of local renewable energy resources, and brings benefits to the users of the microgrid as well as the distribution network operator (DNO). The higher level of the EMS comprises a robust MPC controller which optimizes energy usage and defines a power reference that is tracked by the lower-level real-time controller. The proposed EMS addresses the uncertainty of the predictions of the generation and end-user consumption profiles with the use of the robust MPC controller, which considers the optimization over a control policy where the uncertainty of the power predictions can be compensated either by the battery or main grid power consumption. Simulation results using data from a real urban community showed that when compared with an equivalent (non-robust) deterministic EMS (i.e., an EMS based on the same MPC formulation, but without the uncertainty handling), the proposed EMS based on robust MPC achieved reduced energy costs and obtained a more uniform grid power consumption, safer battery operation, and reduced peak loads.