pH partition hypothesis
The pH partition hypothesis explains how the acidity of the surroundings controls whether a drug can cross a membrane. The core idea is simple: most drugs are weak acids or weak bases that exist in two forms — an uncharged form that dissolves in fat and slips through membranes, and a charged (ionized) form that does not. How much of each form is present depends on the local pH, so pH effectively decides how readily the drug diffuses.
For a weak acid, an acidic environment keeps it mostly uncharged and therefore membrane-permeable; an alkaline environment pushes it toward the charged form that is trapped. A weak base behaves in the opposite way — it is uncharged and absorbable in alkaline conditions and charged in acid. The relationship is quantified by the drug's pKa and the pH using the Henderson–Hasselbalch equation, which gives the ratio of charged to uncharged molecules.
This principle predicts behaviour all along the body. In the acidic stomach, weak acids like aspirin are partly uncharged and can begin to be absorbed; weak bases are charged there and are absorbed better further down in the more alkaline intestine. The same logic governs reabsorption in the kidney tubule and the trapping of drugs in compartments of differing pH (ion trapping).
In reality the hypothesis is a useful simplification, not the whole story. The small intestine's huge surface area means it absorbs most drugs (even weak acids) better than the stomach despite the pH argument, and many drugs also rely on transporters. The hypothesis explains tendencies, not absolutes.
The same pH-partition logic underlies treating aspirin overdose: alkalinizing the urine traps the ionized acid in the tubule and speeds its excretion.