Riboswitches are mRNA domains that bind metabolites and modulate gene expression in cis. We report cocrystal structures of a remarkably compact riboswitch (34 nucleotides suffice for ligand recognition) from Bacillus subtilis that is selective for the essential nucleobase preQ(1) (7-aminomethyl-7-deazaguanine). The structures reveal a previously unrecognized pseudoknot fold and suggest a conserved gene-regulatory mechanism whereby ligand binding promotes sequestration of an RNA segment that otherwise assembles into a transcriptional antiterminator.