In this paper, we propose a control framework for a battery energy storage system to provide simultaneously multiple services to the electrical grid. The objective is to maximise the battery exploitation from these services in the presence of uncertainty (load, stochastic distributed generation, grid frequency). The framework is structured in two phases. In a period-ahead phase, we solve an optimization problem that allocates the battery power and energy budgets to the different services. In the subsequent real-time phase the control set-points for the deployment of such services are calculated separately and superimposed. The control framework is first formulated in a general way and then casted in the problem of providing dispatchability of a medium voltage feeder in conjunction to primary frequency control. The performance of the proposed framework are validated by simulations and real-scale experiments, performed with a grid-connected 560 kWh/720 kVA Li-ion battery energy storage system.