Abstract : In this article, the energy market is a modeled as a Stackelberg game involving three categories of agents: microgrids made of end users sharing the same energy provider, suppliers and generators. The energy production is decentralized involving non-renewables, renewables and demand response performed at the microgrid level. We compute analytically the Nash equilibrium of the game in the generators’ production prices, efforts invested in their capacity, and, in the suppliers’ energy orders. Furthermore, we prove that the generators’ and the demand response prices can be obtained as functions of the price paid by the end users per unit of demand. Finally, coupling the energy and the capacity markets, we design rules for the capacity market guaranteeing the system wide balance and the market opening to new investors while avoiding moral hazard and abuse of dominant positions.