Therapeutic drugs can leak from nanocarriers before reaching their cellular targets. Here we describe the concept of a chemical switch which responds to environmental conditions to alternate between a lipid-soluble state for efficient cargo loading and a water-soluble state for stable retention of cargos inside liposomes. A cue-responsive trigger allows release of the molecular cargo at specific cellular sites. We demonstrate the utility of a specific glycosidic switch for encapsulation of potent anticancer drugs and fluorescent compounds. Stable retention of drugs in liposomes allowed generation of high tumor/blood ratios of parental drug in tumors after enzymatic hydrolysis of the glycosidic switch in the lysosomes of cancer cells. Glycosidic switch liposomes could cure mice bearing human breast cancer tumors without significant weight loss. The chemical switch represents a general method to load and retain cargos inside liposomes, thereby offering new perspectives in engineering safe and effective liposomes for therapy and imaging.