Alfalfa (Medicago sativa), a high-quality forage crop with nitrogen-fixing and soil-improving abilities, is vital for livestock production. Purple acid phosphatases (PAPs), metalloacid phosphatases secreted by plants to the rhizosphere for the hydrolysis of organic phosphorus and growth promotion, remain largely unclear in alfalfa. To address this gap, a genomewide analysis of the MsPAP gene family was conducted to explore its evolution, molecular characteristics, and potential roles in stress tolerance and phosphorus use efficiency. On the basis of the Medicago sativa cv. Zhongmu-1 genome, MsPAP genes were identified and characterized through genomewide screening, phylogenetic analysis, gene structure and conserved motif analysis, chromosomal localization, and collinearity analysis, combined with tissue-specific expression profiling and validation by quantitative real-time polymerase reaction (qRT-PCR). In total, 30 MsPAP genes were identified and unevenly distributed across eight chromosomes. These proteins showed diverse physicochemical properties (169–1,066 amino acids; isoelectric point = 4.87–9.96), were all hydrophilic, and were predicted to localize to chloroplasts, vacuoles, and the cytoplasm. Phylogenetic analysis grouped MsPAPs into six clades and revealed close evolutionary relationships with homologs from Arabidopsis thaliana and Medicago truncatula, which was further supported by collinearity analysis. Expression analysis demonstrated tissue-specific and stress-responsive patterns: Several MsPAP genes were induced by salt, drought, cold, and alkaline stresses, whereas MsPAP23, MsPAP26, and MsPAP20 were strongly upregulated under phosphorus deficiency, indicating roles in the remobilization of phosphorus and stress adaptation. This study provides the first comprehensive characterization of the MsPAP gene family in alfalfa and identifies key candidate genes associated with stress tolerance and phosphorus efficiency, offering valuable genetic resources for breeding improved alfalfa cultivars.