Abstract | An energy community is a legal figure, recently coined by the European Union, that creates a framework to encourage active participation of citizens and local entities in the energy transition to net-zero. In this work, we study the optimal participation of energy communities in day-ahead, reserve, and intraday electricity markets. where energy communities cannot meet their internal demand, and periods where they generate excess electricity. This is because the electricity they generate often comes from variable renewable resources like solar and wind. Electricity market participation is a natural way to ensure they meet their internal demand at all times, and, simultaneously, make the most of the excess electricity. We propose a multi-stage stochastic programming model that captures variable renewable and electricity price uncertainty. The multi-stage aspect models the di¿erent times at which variable renewable generation is considered to be known and electricity prices from di¿erent markets are revealed. This results in a very large scenario tree with 34 stages, and hence a very large optimization problem. Scenario reduction techniques are applied to make the problem tractable. Case studies with real data are discussed, considering di¿erent energy community configurations, to analyse proposed regulatory frameworks in Europe. The added value of considering stochasticity in this problem is also analysed. The motivation to do so is that there are time periods |