We construct steady states of the Euler-Poisson system with a barotropic equation of state as minimizers of a suitably defined energy functional. Their minimizing property implies the non-linear stability of such states against general, i.e., not necessarily spherically symmetric, perturbations. The mathematical approach is based on previous stability results for the Vlasov-Poisson system by Y. Guo and G. Rein, exploiting the energy-Casimir technique. The analysis is conditional in the sense that it assumes the existence of solutions to the initial value problem for the Euler-Poisson system which preserve mass and energy. The relation between the Euler-Poisson and the Vlasov-Poisson system in this context is also explored.