Riboswitches in bacteria regulate gene expression and are targets for antibiotic development. The fluoride riboswitch is essential for bacteria’s survival as it is critical to maintaining the F− ion concentration below the toxic level. The anionic cognate ligand, F− ion, is encapsulated by three Mg2+ ions in a trigonal pyramidal arrangement bound to the ligand-binding domain (LBD) of the riboswitch. The assembly mechanism of this intriguing LBD structure and its role in transcription initiation are not clear. Computer simulations using both coarse-grained and all-atom RNA models show that F− and Mg2+ binding to the LBD are essential to stabilize the LBD structure and tertiary stacking interactions. We propose that the first two Mg2+ ions sequentially bind to the LBD through water-mediated outer-shell coordination. The first bound Mg2+ should undergo a transition to a direct inner shell interaction through dehydration to strengthen its interaction with LBD before the binding of the second Mg2+ ion. The binding of the third Mg2+ and F− to the LBD occurs in two modes. In the first mode, the third Mg2+ binds first to the LBD, followed by F− binding. In the second mode, Mg2+ and F− form a water-mediated ion pair and bind to the LBD simultaneously, which we propose to be the efficient binding mode. We show that the linchpin hydrogen bonds involved in the antiterminator helix formation and transcription initiation are stable only after F− binding. The intermediates populated during riboswitch folding and cognate-ligand binding are potential targets for discovering new antibiotics.