We have developed an automatic traveltime inversion (ATI) method to estimate the macrovelocity model from reflection seismic data. First, we extract the kinematic information (i.e., source/receiver ray parameters, traveltime, and source/receiver coordinates) of locally coherent events using a sparse-decomposition method. And then we evaluate a new strategy to calculate the reflection traveltime residual based on a ray-intersection criterion, eliminating the influence of seismic amplitude to the estimation of the traveltime residual. The velocity model can be updated iteratively by minimizing the traveltime residual functional with a gradient-based method. To obtain a smooth gradient free of artifacts, we first estimate the high-wavenumber components of the functional gradient with a total variation (TV) regularization method and then subtract it from the full gradient. Because the reflection traveltime residual calculation and velocity update are fully automated procedures, the proposed traveltime inversion method is referred to as ATI. We determine with 2D synthetic and field examples that ATI does not need a good starting model. Furthermore, it requires neither low-frequency seismic data nor long-offset acquisition. Nevertheless, the proposed traveltime residual calculation strategy is only valid for the 2D case, which limits its 3D applicability. We explore a possible solution for 3D extension.