An electronic circuit is developed for automating the implementation of a laser frequency-locking technique based on wavelength modulation spectroscopy. The locking scheme uses a zero-crossing as a reference point to line center generated by a derivative-like error signal. Prior implementations have suffered from a limitation in that the zero-crossing must be manually distinguished from the zero signal encountered when the laser is tuned far from line center. This disadvantage is eliminated by developing a circuit that automatically searches the laser's tuning range for an absorption peak and then engages the frequency lock. Both solid state and diode lasers are locked to absorption lines of gases including water vapor and carbon dioxide, with a long-term stabilization to within a few percent of the absorption linewidth.