Polarized deep-inelastic scattering data on longitudinally polarized hydrogen and deuterium targets have been used to determine double-spin asymmetries of cross sections. Inclusive and semi-inclusive asymmetries for the production of positive and negative pions from hydrogen were obtained in a reanalysis of previously published data. Inclusive and semi-inclusive asymmetries for the production of negative and positive pions and kaons were measured on a polarized deuterium target. The separate helicity densities for the up and down quarks and the anti-up, anti-down, and strange sea quarks were computed from these asymmetries in a "leading order" QCD analysis. The polarization of the up-quark is positive and that of the down-quark is negative. All extracted sea quark polarizations are consistent with zero, and the light quark sea helicity densities are flavor symmetric within the experimental uncertainties. First and second moments of the extracted quark helicity densities in the measured range are consistent with fits of inclusive data. © 2005 The American Physical Society.