Erectile dysfunction (ED) is a common complication of diabetes mellitus. Phosphodiesterase-5 (PDE5) inhibitors, which inhibit the breakdown of intracellular cyclic guanosine monophosphate (cGMP), are used to treat diabetic ED. Caffeine, a nonselective PDE inhibitor used in our daily diet, is controversial regarding its effect on erectile function. To investigate the effect of caffeine on erectile function in diabetic rat models and explore the mechanism, male Sprague-Dawley rats were injected with streptozotocin to induce diabetes mellitus. The rats with blood glucose levels above 300 mg/dL were selected for the study. The rats were divided into 4 groups: group A (normal control rats), group B (diabetic rats treated with normal saline), group C (diabetic rats treated with caffeine, 10 mg/kg per day), and group D (diabetic rats treated with caffeine, 20 mg/kg per day). After 8 weeks of treatment, intracavernous pressure (ICP) was measured to assess erectile function. The radioimmunoassay was used to evaluate the level of cGMP in the cavernosum. The ICP and the cavernous cGMP decreased significantly in the diabetic rats compared with normal controls. An 8-week administration of caffeine at the given dosages increased the ICP and cavernous cGMP in diabetic rats. Caffeine consumption improved the erectile function of diabetic rats by up-regulating cavernous cGMP.