The nonlinear Zeeman effect can induce splitting and asymmetries of magnetic-resonance lines in the geophysical magnetic field range. This is a major source of heading error for scalar atomic magnetometers. We demonstrate a method to suppress the nonlinear Zeeman effect and heading error based on spin locking. In an all-optical synchronously pumped magnetometer with separate pump and probe beams, we apply a radio-frequency field which is in-phase with the precessing magnetization. In an earth-range field, a multi-component asymmetric magnetic-resonance line with ? 60 Hz width collapses into a single peak with a width of 22 Hz, whose position is largely independent of the orientation of the sensor. The technique is expected to be broadly applicable in practical magnetometry, potentially boosting the sensitivity and accuracy of earth-surveying magnetometers by increasing the magnetic resonance amplitude, decreasing its width and removing the important and limiting heading-error systematic.