We have used chemical modification analysis to probe the solution structure of the hairpin ribozyme. The modifying reagents dimethylsulfate, 1-cyclohexyl-N'-[2-(N-methylmorpholino) ethyl-carbodiimide-p-toluenesulfonate, kethoxal, diethylpyrocarbonate and (2,12-dimethyl-3,7,11,17- tetraazabicyclo [11.3.1]heptadeca-1(17),2,11,13,15-pentaenato) nickel(II) perchlorate were used to probe functional groups that participate in Watson-Crick and non-canonical base-pairs. Our results confirm the existence of four short helices (3 to 6 bp) within the ribozyme-substrate complex, and demonstrate that one intramolecular helix (helix 4) is comprised of three base-pairs rather than the previously suggested five. In the absence of magnesium, the ribozyme is observed to fold into its secondary structure. Upon addition of magnesium, a striking difference in chemical modification is observed, particularly at sites within the ribozyme's large internal loop (loop B) that are essential for catalytic function (bases 21 to 26). Moreover, magnesium-dependent folding clearly destabilizes an A-U base-pair in a region where a proposed bend is required to juxtapose the catalytically essential loops A and B. Upon addition of substrate, no changes are observed in the structure of helix 3, loop B or helix 4. However, strong protection of bases in the substrate-binding domain is observed, including those located across internal loop A. The modification data are consistent with the formation of a previously proposed tertiary structure motif within loop B that includes non-canonical G-A, A-U and A-A base-pairs, and that is identical with those identified by NMR analysis of loop E of 5 S rRNA and the sarcin/ricin loop of 28 S rRNA. Our results indicate that the hairpin ribozyme adopts a stable magnesium-dependent tertiary structure to which the substrate binds without inducing major conformational changes, and that substrate recognition is likely to involve non-canonical base-pairs between the ribozyme and substrate sequences adjacent to the cleavage site.