Patients with liver disease with overt or minimal hepatic encephalopathy show impaired intellectual capacity. The underlying molecular mechanism remains unknown. Rats with portacaval anastomosis or with hyperammonemia without liver failure also show impaired learning ability and impaired function of the glutamate-nitric oxide-cyclic guanine monophosphate (glutamate-NO-cGMP) pathway in brain. We hypothesized that pharmacological manipulation of the pathway in order to increase cGMP content could restore learning ability. We show by in vivo brain microdialysis that chronic oral administration of sildenafil, an inhibitor of the phosphodiesterase that degrades cGMP, normalizes the function of the glutamate-NO-cGMP pathway and extracellular cGMP in brain in vivo in rats with portacaval anastomosis or with hyperammonemia. Moreover, sildenafil restored the ability of rats with hyperammonemia or with portacaval shunts to learn a conditional discrimination task. In conclusion, impairment of learning ability in rats with chronic liver failure or with hyperammonemia is the result of impairment of the glutamate-NO-cGMP pathway. Moreover, chronic treatment with sildenafil normalizes the function of the pathway and restores learning ability in rats with portacaval shunts or with hyperammonemia. Pharmacological manipulation of the pathway may be useful for the clinical treatment of patients with overt or minimal hepatic encephalopathy.