The homeodomain-leucine zipper (HD-Zip) transcription factors are plant-specific proteins that play pivotal roles in regulating various biological processes. Here, we conducted a comprehensive genome-wide analysis of the HD-Zip transcription factor family in alfalfa (Medicago sativa L.), identifying a total of 40 MsHDZ genes. Phylogenetic analysis classified the MsHDZ genes into four subfamilies (I-IV). Gene structure and conserved protein motif analyses revealed a high degree of structural conservation and functional diversity among the MsHDZs. Chromosomal mapping showed that MsHDZ genes are unevenly distributed across the alfalfa genome. Expression profiling indicated that MsHDZ genes exhibit tissue-specific expression patterns and are significantly induced under drought and salt stresses. Notably, the overexpressing MsHDZ18 enhanced drought tolerance in transgenic plants, suggesting its critical role in abiotic stress responses. These findings provide valuable insights into the functional roles of HD-Zip transcription factors in alfalfa.