A preconditioner defined by an algebraic multigrid cycle for a damped Helmholtz operator is proposed for the Helmholtz equation. This approach is well suited for acoustic scattering problems in complicated computational domains and with varying material properties. The spectral properties of the preconditioned systems and the convergence of the GMRES method are studied with linear, quadratic, and cubic finite element discretizations. Numerical experiments are performed with two-dimensional problems describing acoustic scattering in a cross-section of a car cabin and in a layered medium. Asymptotically the number of iterations grows linearly with respect to the frequency while for lower frequencies the growth is milder. The proposed preconditioner is particularly effective for low-frequency and mid-frequency problems.