We develop a new method to constrain the star formation histories , dust attenuation and stellar masses of galaxies . It is based on two stellar absorption line indices , the 4000 Å break strength and the Balmer absorption line index H \delta _ { A } . Together , these indices allow us to constrain the mean stellar ages of galaxies and the fractional stellar mass formed in bursts over the past few Gyr . A comparison with broad band photometry then yields estimates of dust attenuation and of stellar mass . We generate a large library of Monte Carlo realizations of different star formation histories , including starbursts of varying strength and a range of metallicities . We use this library to generate median likelihood estimates of burst mass fractions , dust attenuation strengths , stellar masses and stellar mass-to-light ratios for a sample of 122,808 galaxies drawn from the Sloan Digital Sky Survey . The typical 95 % confidence range in our estimated stellar masses is \pm 40 % . We study how the stellar mass-to-light ratios of galaxies vary as a function of absolute magnitude , concentration index and photometric pass-band and how dust attenuation varies as a function of absolute magnitude and 4000 Å break strength . We also calculate how the total stellar mass of the present Universe is distributed over galaxies as a function of their mass , size , concentration , colour , burst mass fraction and surface mass density . We find that most of the stellar mass in the local Universe resides in galaxies that have , to within a factor of about 2 , stellar masses \sim 5 \times 10 ^ { 10 } M _ { \odot } , half-light radii \sim 3 kpc , and half-light surface mass densities \sim 10 ^ { 9 } M _ { \odot } kpc ^ { -2 } . The distribution of D _ { n } ( 4000 ) is strongly bimodal , showing a clear division between galaxies dominated by old stellar populations and galaxies with more recent star formation .