The bacterial alarmone 5-aminoimidazole-4-carboxamide riboside 5'-triphosphate (AICAR triphosphate or ZTP), derived from the monophosphorylated purine precursor ZMP, accumulates during folate starvation. ZTP regulates genes involved in purine and folate metabolism through a cognate riboswitch. The linker connecting this riboswitch's two subdomains varies in length by over 100 nucleotides. In this paper, we report the cocrystal structure of the Fusobacterium ulcerans riboswitch bound to ZMP, which spans the two subdomains whose interface also comprises a pseudoknot and ribose zipper. The riboswitch recognizes the carboxamide oxygen of ZMP through an unprecedented inner-sphere coordination with a Mg<
sup>
2+<
/sup>
ion. We show that the affinity of the riboswitch for ZMP is modulated by the linker length. Notably, ZMP can simultaneously bind to the two subdomains even when they are synthesized as separate RNAs. Finally, the ZTP riboswitch demonstrates how specific small-molecule binding can drive association of distant noncoding-RNA domains to regulate gene expression.