Numerous classes of riboswitches have been found to regulate bacterial gene expression in response to physiological cues, offering new paths to antibacterial drugs. As common studies of isolated riboswitches lack the functional context of the transcription machinery, we here combine single-molecule, biochemical, and simulation approaches to investigate the coupling between co-transcriptional folding of the pseudoknot-structured preQ1 riboswitch and RNA polymerase (RNAP) pausing. We show that pausing at a site immediately downstream of the riboswitch requires a ligand-free pseudoknot in the nascent RNA, a precisely spaced sequence resembling the pause consensus, and electrostatic and steric interactions with the RNAP exit channel. While interactions with RNAP stabilize the native fold of the riboswitch, binding of the ligand signals RNAP release from the pause. Our results demonstrate that the nascent riboswitch and its ligand actively modulate the function of RNAP and vice versa, a paradigm likely to apply to other cellular RNA transcripts.