Background In different animal models, a histone deacetylase (HDAC) inhibitor, sodium butyrate (NaBu) reduced inflammation, oxidative stress and fibrosis which were involved in the pathogenesis of erectile dysfunction (ED), but whether NaBu could improve ED in an experimental animal model of benign prostate hyperplasia (BPH) was not known. Objective To investigate the preventive effect of NaBu on ED in a partial bladder outlet obstruction (PBOO) rat model. Materials and methods PBOO was induced by partial urethral obstruction. NaBu (20 mg/kg/day) was administered orally to rats for 6 weeks after creation of PBOO. In vivo erectile responses, in vitro relaxation and contraction responses in cavernosal tissue were measured. Real-time polymerase chain reaction (RT-PCR) and Western blot were performed to determine the gene and protein expression. Inflammation, fibrosis, and localization of proteins were evaluated using histological techniques. HDAC activity and tumor necrosis factor (TNF)-alpha levels were measured in penile tissues. Results NaBu improved decreased intracavernosal pressure/mean arterial pressure, nitrergic and endothelium-dependent relaxation responses, and contractile responses to phenylephrine and electrical field stimulation in the PBOO group without affecting increased bladder weight. Increased endothelial nitric oxide synthase (eNOS), transforming growth factor (TGF)-beta 1, and nuclear factor kappa B (NF-kappa B) gene levels in PBOO group were ameliorated by NaBu treatment. The administration of NaBu to PBOO rats significantly increased neuronal NOS (nNOS) and decreased TGF-beta 1 protein expression. The nuclear/cytosolic ratio of NF-kappa B demonstrated a decrease in PBOO and all treatment groups compared to control. A significant increase in the nuclear-to-cytoplasmic ratio of nuclear factor erythroid 2-related factor 2 (Nrf2) after PBOO was reduced by the treatment. Both eNOS and inducible NOS (iNOS) protein expression, together with TNF-alpha levels did not differ in the penile tissue of all groups. In histological analysis, increased TGF-beta 1 protein expression and fibrosis, as well as decreased nNOS protein in PBOO, were reversed by the treatment. NaBu did not normalize moderate inflammation in obstructed rats. An increase in the HDAC activity in PBOO was significantly suppressed by NaBu. Discussion Inhibition of the HDAC activity by NaBu in penile tissue could ameliorate fibrosis-associated changes induced by PBOO. Conclusion NaBu promotes recovery of erectile function, and also significantly prevents penile fibrosis and normalizes TGF-beta 1 and nNOS protein expression in a rat model of PBOO. The HDAC pathway may present a promising target to prevent ED in patients with BPH.