We present a method to optimize absorption cells for precise wavelength calibration in the near-infrared. We apply it to design and optimize methane isotopologue cells for precision radial velocity measurements in the K band. We also describe the construction and installation of two such cells for the CSHELL spectrograph at NASA’s IRTF. We have obtained their high-resolution laboratory spectra, which we can then use in precision radial velocity measurements and which can also have other applications. In terms of obtainable RV precision, methane should outperform other proposed cells, such as the ammonia cell (^(14)NH_3) recently demonstrated on CRIRES/VLT. The laboratory spectra of the ammonia and methane cells show strong absorption features in the H band that could also be exploited for precision Doppler measurements. We present spectra and preliminary radial velocity measurements obtained during our first-light run. These initial results show that a precision down to 20-30 m s^(-1)can be obtained using a wavelength interval of only 5 nm in the K band and S/N ∼ 150. This supports the prediction that a precision down to a few meters per second can be achieved on late-M dwarfs using the new generation of NIR spectrographs, thus enabling the detection of terrestrial planets in their habitable zones. Doppler measurements in the NIR can also be used to mitigate the radial velocity jitter due to stellar activity, enabling more efficient surveys on young active stars.