Objective To determine the prevalence of workplace violence among Peruvian medical residents and to evaluate the association between medical specialty and workplace violence per type of aggressor. Methods This was a cross-sectional secondary analysis that used data from the Peruvian Medical Residents National Survey 2016 (ENMERE-2016). The outcome of interest was workplace violence, including physical and verbal violence, which were categorized according to the perpetrator of violence (patients/relatives and worker-to-worker). Primary exposure was the medical specialty, categorized as clinical, surgical, and other specialties. To evaluate the associations of interest, we estimated adjusted prevalence ratios (PR) with their respective 95% confidence intervals (95% CI) using Poisson regression models with robust variances. Results A total of 1054 Peruvian medical residents were evaluated. The mean age was 32.6 years and 42.3% were female. Overall 73.4% reported having suffered of workplace violence sometime during the residency, 34.4% reported violence from patients/relatives, and 61.1% reported worker-to-worker violence. Compared with clinical residents, surgical residents had a lower prevalence of violence from patients/relatives (PR: 0.71; 95% CI: 0.59–0.87), but a higher prevalence of worker-to-worker violence (PR: 1.11, 95% CI: 1.01–1.23). Conclusion Nearly three quarters of medical residents reported having suffered workplace violence sometime during their residency. Compared with clinical residents, surgical residents had lower rates of violence from patients/relatives, but higher rates of worker-to-worker violence; while residents from non-clinical and non-surgical specialties had a lower prevalence of both types of violence.