Full exploitation of the physics potential of a future International Linear Collider will require the use of polarized electron and positron beams. Experiment E166 at the Stanford Linear Accelerator Center (SLAC) has demonstrated a scheme in which an electron beam passes through a helical undulator to generate photons (whose first-harmonic spectrum extended to 7.9MeV) with circular polarization, which are then converted in a thin target to generate longitudinally polarized positrons and electrons. The experiment was carried out with a one-meter-long, 400-period, pulsed helical undulator in the Final Focus Test Beam (FFTB) operated at 46.6GeV. Measurements of the positron polarization have been performed at five positron energies from 4.5 to 7.5MeV. In addition, the electron polarization has been determined at 6.7MeV, and the effect of operating the undulator with a ferrofluid was also investigated. To compare the measurements with expectations, detailed simulations were made with an upgraded version of Geant4 that includes the dominant polarization-dependent interactions of electrons, positrons, and photons with matter. The measurements agree with calculations, corresponding to 80% polarization for positrons near 6MeV and 90% for electrons near 7MeV.