According to several studies, there is an association between human papillomavirus (HPV) and breast cancer. Therefore, detection and genotyping of HPV seem important. The present study aimed to investigate the presence of HPV DNA in breast tissues by analyzing the L1 gene. This case-control study was conducted on 63 formalin-fixed paraffin-embedded (FFPE) tissues of invasive ductal carcinoma (IDC) as the case group and 32 FFPE tissues of fibroadenoma as the control group. HPV DNA was detected using the polymerase chain reaction assay. Positive samples were then subjected to genotyping. All statistical analyses were performed in SPSS version 22.0. The patients' age ranged from 15 to 92 years, with a mean age of 43.54±16.36 years. HPV DNA was detected in 17/95 (17.89%) samples, including 9/32 (28.12%) fibroadenoma samples and 8/63 (12.69%) IDC samples. No significant difference was observed regarding the presence of HPV DNA between the IDC and fibroadenoma tissues (P=0.08). However, a significant difference was found in the detection of high-risk HPV (HR-HPV) between the case and control groups (P=0.03). In the case group, 87.5% of the detected viruses (7/8 samples) were HR-HPV, while in the control group, 22.22% of positive samples (2/9 samples) were HR-HPV (P=0.03). Based on the results, HR-HPV and low-risk HPV genotypes were detected in 53% (9/17) and 47% (8/17) of positive samples, respectively. In this study, 12.69% of IDC samples were positive for HPV genomes, and HR-HPV was detected in 87.5% of these samples. The present results suggest the important role of HR-HPV in the development of breast cancer.