A method is proposed for producing monoergetic, high-quality ion beams in vacuum, via direct acceleration by the electromagnetic field of two counterpropagating, variable-frequency lasers: ions are trapped and accelerated by a beat-wave structure with variable phase velocity, allowing for fine control over the energy and the charge of the beam via tuning of the frequency variation. The physical mechanism is described with a one-dimensional theory, providing the general conditions for trapping and scaling laws for the relevant features of the ion beam. Two-dimensional, electromagnetic particle-in-cell simulations, in which hydrogen gas is considered as an ion source, confirm the validity and the robustness of the method.