Riboswitches are structural elements of mRNA involved in the regulation of gene expression by responding to specific cellular metabolites. To fulfil their regulatory function, riboswitches prefold into an active state, the so-called binding competent form, that guarantees metabolite binding and allows a consecutive refolding of the RNA. Here, we describe the folding pathway to the binding competent form as well as the ligand free structure of the moaA riboswitch of E. coli. This RNA proposedly responds to the molybdenum cofactor (Moco), a highly oxygen-sensitive metabolite, essential in the carbon and sulfur cycles of eukaryotes. K+- and Mg2+-dependent footprinting assays and spectroscopic investigations show a high degree of structure formation of this RNA already at very low ion-concentrations. Mg2+ facilitates additionally a general compaction of the riboswitch towards its proposed active structure. We show that this fold agrees with the earlier suggested secondary structure which included also a long-range tetraloop/tetraloop-receptor like interaction. Metal ion cleavage assays revealed specific Mg2+-binding pockets within the moaA riboswitch. These Mg2+ binding pockets are good indicators for the potential Moco binding site, since in riboswitches, Mg2+ was shown to be necessary to bind phosphate-carrying metabolites. The importance of the phosphate and of other functional groups of Moco is highlighted by binding assays with tetrahydrobiopterin, the reduced and oxygen-sensitive core moiety of Moco. We demonstrate that the general molecular shape of pterin by its own is insufficient for the recognition by the riboswitch