The increasing penetration of renewable energy sources is strongly linked to the development of voltage source converters used in their connection to the grid. As a result, in the near future of an inverter-dominated power system it will be a requirement for renewable generation to provide ancillary services in order to compensate for the absence of synchronous generation. In this scenario, the use of energy storage systems along with advanced control algorithms mimicking the dynamic behaviour of the traditional generators will be of utmost importance. This paper deals with a renewable energy source interfaced with a voltage source converter and comprising an energy storage system in the DC bus. Particularly, a new energy management algorithm for the DC-bus based on a three levels hierarchical control is proposed, which is able to simultaneously provide ancillary services, maintain the state of charge of the storage system within the permissible limits and use it to control the DC bus voltage. The control strategy is validated experimentally using a prototype with results evidencing a reliable and stable operation.