The primary cause of hepatic encephalopathy is the impaired ability of the liver to remove toxins from the bloodstream. These toxins, primarily ammonia, originate from the gut and are typically detoxified by the liver. In liver dysfunction, ammonia and other substances like mercaptans and short-chain fatty acids accumulate, leading to neurological impairment. Factors that exacerbate this condition include gastrointestinal bleeding, infections, and renal failure.