Experimental autoimmune prostatitis (EAP) is a well-established model induced by an autoimmune response to prostate antigen. The symptomatic, pathological, and immunological characteristics of EAP animals are highly consistent with human chronic prostatitis/chronic pelvic pain syndrome (CP/CPPS), which makes EAP an ideal model for this disease. Here, we investigate the influence of EAP on male rat sexual function and the efficacy of anti-inflammatory therapy with celecoxib. EAP rat models were established using male Wistar rats. Rats were randomly assigned to a normal control group, an EAP model group, or an EAP model with celecoxib treatment group (celecoxib group). Behavioral changes, sexual behavioral changes, and erectile function were estimated using an open-field test, a sucrose consumption test, mating experiments, and by intracavernous pressure/mean arterial pressure ratio (ICP/MAP). Histological changes in the prostate were observed by HE staining, and the serum inflammatory factors IL-1β and TNF-α levels were measured by enzyme-linked immunosorbent assay. In addition, serotonin (5-hydroxytryptamine, 5-HT), 5-HT 1A receptor, 5-HT 2C receptor, and serotonin transporter (SERT) expression levels in the hippocampus and spinal cord (T13-L1, L5-S2) were examined by immunohistochemistry and western blot analysis. Results showed that EAP rats exhibited characteristics of depression, decreased sexual drive, premature ejaculation, and increased threshold of penile erection. Moreover, all these changes were effectively alleviated by celecoxib. Significant increases in prostatic interstitial infiltration by inflammatory cells and in serum IL-1β and TNF-α levels were observed in EAP rats, and these were partially reduced by celecoxib. Additionally, the expression pattern of serotonin system regulators in the hippocampus and spinal cord were altered in EAP model rats, including a decrease in 5-HT levels and an increase in 5-HT 1A receptor levels. In conclusion, autoimmune prostatitis impaired rat sexual function, and this was effectively prevented by anti-inflammatory therapy with celecoxib. Moreover, a serotonin system disorder in the central nervous system was likely mediated via inflammation in EAP rats.