A precise measurement of the cross section of the process $e^+e^-topi^+pi^-(gamma)$ from threshold to an energy of 3GeV is obtained with the initial-state radiation (ISR) method using 232fb$^{-1}$ of data collected with the BaBar detector at $e^+e^-$ center-of-mass energies near 10.6GeV. The ISR luminosity is determined from a study of the leptonic process $e^+e^-tomu^+mu^-(gamma)gamma_{rm ISR}$, which is found to agree with the next-to-leading-order QED prediction to within 1.1%. The cross section for the process $e^+e^-topi^+pi^-(gamma)$ is obtained with a systematic uncertainty of 0.5% in the dominant $rho$ resonance region. The leading-order hadronic contribution to the muon magnetic anomaly calculated using the measured $pipi$ cross section from threshold to 1.8GeV is $(514.1 pm 2.2({rm stat}) pm 3.1({rm syst}))times 10^{-10}$.