ImportanceInvestigating racial and ethnic discrimination in medical education is crucial for addressing disparities and fostering an inclusive environment.ObjectiveTo assess how racial and ethnic discrimination in medical school is associated with personal and professional identity formation (PPIF) by race and ethnicity.Design, Setting, and ParticipantsThis retrospective cross-sectional study used deidentified data on 37 610 medical students who matriculated in 2014 or 2015 and took the Association of American Medical Colleges Graduation Questionnaire (GQ) between 2016 and 2020. Statistical analysis was performed from September 1 to November 20, 2023.ExposuresExperiences of racial and ethnic discrimination were assessed through responses to 3 GQ questions about denial of opportunities, offensive remarks or names, and lower evaluations or grades due to race or ethnicity.Main Outcomes and MeasuresPersonal and professional development were measured as 2 separate outcomes using 2 GQ statements rated on a 5-point Likert scale (where 1 indicated strongly disagree and 5 indicated strongly agree): “My medical school has done a good job fostering and nurturing my development as a person” and “My medical school has done a good job fostering and nurturing my development as a physician.” Variables of personal and professional development were both dichotomized.ResultsOf 37 610 medical students, 18 200 (48.4%) were female, and 19 410 (51.6%) were male; 2458 (6.5%) were African American or Black, 7801 (20.7%) were Asian, 2430 (6.5%) were Hispanic, 21 380 (56.9%) were White, 2404 (6.4%) were multiracial, and 1137 (3%) were other race or ethnicity. Most respondents attested that their medical school fostered their personal (27 272 [72.5%]) and professional (34 560 [91.9%]) development. African American or Black students reported the lowest rates of personal (1603 of 2458 [65.2%]) and professional (2182 of 2458 [88.8%]) development, and experienced lower likelihoods of personal (adjusted risk ratio [ARR], 0.89 [95% CI, 0.86-0.93]) and professional (ARR, 0.95 [95% CI, 0.94-0.97]) development than White students. Racial discrimination was inversely associated with development, with the highest PPIF rates among those never experiencing discrimination (personal, 25 089 of 33 508 [74.9%]; and professional, 31 257 of 33 508 [93.3%]). Those experiencing isolated discrimination (personal: ARR, 0.83 [95% CI, 0.80-0.87]; professional: ARR, 0.92 [95% CI, 0.91-0.95]) and recurrent discrimination (personal: ARR, 0.63 [95% CI, 0.60-0.66]; professional: ARR, 0.82 [95% CI, 0.80-0.84]) had relatively lower likelihoods of PPIF. African American or Black students experienced the highest rate of recurrent discrimination (543 of 2458 [22.1%]). No significant PPIF risk differences were found for other racial and ethnic groups underrepresented in medicine without discrimination compared with White students without discrimination, but all groups with recurrent discrimination had relatively lower PPIF risk.Conclusions and RelevanceIn this cross-sectional study of US medical students, racial and ethnic discrimination was associated with lower PPIF across all racial and ethnic groups compared with White students without such experiences. African American or Black students disproportionately faced this discrimination. Systemic changes in medical education are needed to combat discrimination and ensure equity in holistic student development.