In 2020, there were approximately 50,865 anal cancer cases and 36,068 penile cancer cases worldwide. HPV is considered the main causal agent for the development of anal cancer and one of the causal agents responsible for the development of penile cancer. The aim of this epidemiological, descriptive, retrospective study was to describe the burden of hospitalization associated with anal neoplasms in men and women and with penis neoplasms in men in Spain from 2016 to 2020. The National Hospital Data Surveillance System of the Ministry of Health, Conjunto Mínimo Básico de Datos, provided the discharge information used in this observational retrospective analysis. A total of 3,542 hospitalizations due to anal cancer and 4,270 hospitalizations due to penile cancer were found; For anal cancer, 57.4% of the hospitalizations occurred in men, and these hospitalizations were also associated with significantly younger mean age, longer hospital stays and greater costs than those in women. HIV was diagnosed in 11.19% of the patients with anal cancer and 1.74% of the patients with penile cancer. The hospitalization rate was 2.07 for men and 1.45 for women per 100,000 in anal cancer and of 4.38 per 100,000 men in penile cancer. The mortality rate was 0.21 for men and 0.12 for women per 100,000 in anal cancer and 0.31 per 100.000 men in penile cancer and the case-fatality rate was 10.07% in men and 8,26% in women for anal cancer and 7.04% in penile cancer. HIV diagnosis significantly increased the cost of hospitalization. For all the studied diagnoses, the median length of hospital stays and hospitalization cost increased with age. Our study offers relevant data on the burden of hospitalization for anal and penile cancer in Spain. This information can be useful for future assessment on the impact of preventive measures, such as screening or vaccination in Spain.