Noise-immune cavity-enhanced optical heterodyne molecular spectroscopy (NICE-OHMS) is a powerful tool for trace gas detection, which is based on the combination of frequency modulation spectroscopy (FMS) for reduction of 1/f noise, especially residual intensity noise, and cavity enhanced absorption spectroscopy (CEAS) for prolonging the interaction length between the laser and the targeted gas. Because of the locking of modulation frequency in FMS to the free spectral range (FSR) of the cavity, NICE-OHMS is immune to the frequency-to-amplitude noise, which is a main limitation to CEAS. Moreover, due to the building of high power inside the cavity, NICE-OHMS can easily saturate the molecular absorption thus obtain sub-Doppler spectroscopy, which possess a high resolution and odd symmetry, and thus can act as a frequency discriminator for the locking of the laser frequency to the transition center. In this paper, a fiber laser based NICE-OHMS system is established and the laser frequency is locked to the sub-Doppler absorption line of NH3 by sub-Doppler NICE-OHMS. To avoid the complex design of high-Q-factor bandpass filter at radio frequency, the frequency νpdh, used for Pound-Drever-Hall (PDH) locking, is generated by the beat frequencies νfsr and νdvb, which are used for NICE-OHMS signal and DeVoe-Brewer (DVB) locking, respectively. The performances of PDH and DVB locking are analysed by the frequency distribution deduced from the error signals, which result in frequency deviations of 4.3 kHz and 0.38 kHz, respectively. Then, the CEAS signal and NICE-OHMS signal in the dispersive phase for the measurement of NH3 at 1.53 μm under 70 mTorr are obtained, which show signal-to-noise ratios of 3.3 dB and 45.5 dB, respectively. Due to the high power built in the cavity, the sub-Doppler structure in the NICE-OHMS signal is obtained in the center of the absorption tansition with a satruation degree of 0.22, which is evaluated by the amplitude ratio between sub-Doppler and Doppler-broadened signals. The linewidth (full width at half maximum) of the sub-Doppler signal of 2.05 MHz is obtained, which is calibrated by the time interval between carrier and sideband. The free-running drift of the laser frequency is estimated by the NICE-OHMS signal and results in 50 MHz over 3 h. While, with locking, the relative deviation of the laser frequency is reduced to 16.3 kHz. In order to evaluate the long term stability of the system, the frequency deviation over 3 h is measured. The Allen deviation analysis shows that the white noise is the main noise of the system in the integration time shorter than 10 s. And the frequency stability can reach to 1.6×10-12 in an integration time of 136 s.