We present an analytic formulation for the equilibrium gas density profile of early-type galaxies that explicitly includes the contribution of stars in the gravitational potential . We build a realistic model for an isolated elliptical galaxy and explore the equilibrium gas configurations as a function of multiple parameters . For an assumed central gas temperature k _ { B } T _ { 0 } = 0.6 keV , we find that neglecting the gravitational effects of stars , which can contribute substantially in the innermost regions , leads to an underestimate of the enclosed baryonic gas mass by up to \sim 65 % at the effective radius , and by up to \sim 15 % at the NFW scale radius , depending on the stellar baryon fraction . This formula is therefore important for estimating the baryon fraction in an unbiased fashion . These new hydrostatic equilibrium solutions , derived for the isothermal and polytropic cases , can also be used to generate more realistic initial conditions for simulations of elliptical galaxies . Moreover , the new formulation is relevant when interpreting X-ray data . We compare our composite isothermal model to the standard \beta -model used to fit X-ray observations of early-type galaxies , to determine the value of the NFW scale radius r _ { s } . Assuming a 10 % stellar baryon fraction , we find that the exclusion of stars from the gravitational potential leads to ( i ) an underestimate of r _ { s } by \sim 80 % , and to ( ii ) an overestimate of the enclosed dark matter at r _ { s } by a factor of \sim 2 , compared to the equivalent \beta -model fit results when stars are not taken into account . For higher stellar mass fractions , a \beta -model is unable to accurately reproduce our solution , indicating that when the observed surface brightness profile of an isolated elliptical galaxy is found to be well fitted by a \beta -model , the stellar mass fraction can not be much greater than \sim 10 % .