Riboswitches are natural RNA sensors that affect gene control via their capacity to bind small molecules. Their prevalence in higher eukaryotes is unclear. We discovered a post-transcriptional mechanism in plants that uses a riboswitch to control a metabolic feedback loop through differential processing of the precursor RNA 3' terminus. When cellular thiamin pyrophosphate (TPP) levels rise, metabolite sensing by the riboswitch located in TPP biosynthesis genes directs formation of an unstable splicing product, and consequently TPP levels drop. When transformed in plants, engineered TPP riboswitches can act autonomously to modulate gene expression. In an evolutionary perspective, a TPP riboswitch is also present in ancient plant taxa, suggesting that this mechanism is active since vascular plants emerged 400 million years ago.