This work presents an optimization framework for the optimal scheduling of a multi-energy microgrid based on Mixed-Integer Programming techniques and consisting of a number of aggregated end-users. With the objective of satisfying the microgrid's electricity and heat demands in a cost-optimal way, the microgrid includes several technologies such as micro combined heat and power units, gas turbines, heat pumps, renewable energy sources, exchanges with the main grid, as well as flexibility providers such as energy storage systems, electric vehicles, and demand response. One salient feature of the proposed framework is that it considers the contribution of power generating sources in the ancillary services provision, both up and down, providing an additional income for their operation and enhancing the grid operation. An illustrative case study has been used to test the applicability of the proposed approach in both economic and operational terms. The results underscore the significance of including the ancillary services market as a revenues source to the MES as well as the fact that the participation of various resources in both energy and ancillary services markets affects the operational scheduling of the microgrid, and the services provided by the flexibility providers play a major role in the overall cost reduction. System operators, aggregators, and market participants can utilize the proposed optimization framework to determine their operational and investment strategies for optimal resource utilization and portfolio selection.