Recorded surface waves often provide reasonable estimates of the Shear wave velocity in the near surface. However, these estimates tend to be low in resolution considering that they depend on dispersion nature of the fundamental mode of surface waves. We present a surface-wave inversion method that inverts for the S-wave velocity from the fundamental- and higher-modes of Rayleigh waves. The proposed method aims to maximize the similarity of the phase velocity (f − v) spectrum of the surface waves with all-Rayleigh wave modes (if they exist) in the inversion. The f − v spectrum is calculated using the linear Radon transform and by using a local similarity-based objective function, we do not need to pick velocities in the spectrum plots. Thus, the best match between the predicted and observed data f − v spectrum provides the optimal estimation of S-wave velocity. We derive the gradient of the proposed objective function using the adjoint-state method and solve the optimization problem using the LBFGS method. Our method can invert for lateral velocity variations, include all-mode dispersions, and mitigate the local minimum problem in full waveform inversion with a reasonable computation cost. Results with synthetic and field data illustrate the benefits and limitations of this method.