Dairy slurry could be a significant source of nitrogen (N) for plants, but mismanagement can lead to atmospheric ammonia losses or nitrate leaching into groundwater. To make the use of dairy slurry efficient and reasonable, the loss of N pollution to the environment should be reduced. We used repacked lysimeters to comprehensively determine ammonia emission and N leaching losses in an alfalfa–soil system. The application of dairy slurry had no significant effect on alfalfa yield at the same rate of N application in comparison to chemical fertilizer, and adding humic acids significantly increased yield by about 12%. However, the application of dairy slurry increased the ammonia emission rate significantly, leading to an increase in the cumulative amount of ammonia emission, while the addition of humic acids reduced the ammonia emissions by 11%. Chemical fertilizer and dairy slurry application significantly increased nitrate leaching compared to the control treatment, while the addition of humic acids can significantly reduce ammonium N leaching. Dairy slurry was proven to be as effective as chemical N fertilizer in achieving the optimum biomass, and adding humic acids can significantly reduce N loss to the atmosphere and groundwater. This study showed the possibility of replacing chemical fertilizer with dairy slurry in alfalfa production and the advantages of humic acids’ addition to alfalfa to maintain production yield and improve environmental friendliness.