A deep borehole through Ribbon Reef 5 in the Great Barrier Reef off north-eastern Australia has identified a variety of cements, including epitaxial, radial prismatic and spherular aragonite, together with blocky, prismatic and fibrous calcite. These cements are discontinuously arranged within the sequence that consists predominantly of grainstones but locally includes clotted muddy and filamentous textures that may be of microbial origin. Calcite cements vary in morphology with groups of crystals that include acute scalenohedral, rhombohedral and flattened concordant terminations; these show varying densities of inclusions that locally define growth zones and in some terminations divide in the manner of ‘split crystals’ to form fibrous fringes. Morphological changes in calcite are inferred to reflect changes in water chemistry and crystal growth rates at the time of growth, allied to their relationship to the palaeo-water table, and linked in turn to changes in sea-level. Neomorphism and dissolution are widespread and variations in the severity of both imply response to the degree of undersaturation of pore waters that at times were probably balanced within very narrow limits. A total of 10 depositional units are identified. Those units at the base of the borehole reflect deposition and diagenesis within a marine environment. The influence of meteoric waters, indicated by stable isotopes, is first apparent at the top of Unit 1 and in Unit 2 (184 to 155 m below sea floor). Petrographic evidence of vadose conditions appears at the tops of Unit 3 (131 to 99 m below sea floor). Units 4 to 8, all deposited under marine conditions, provide isotopic evidence of meteoric or mixing-zone waters and petrographic indicators of vadose conditions, typically at the top of the units. Evidence indicates that in Unit 5 the water table was mobile and Units 6a, 6b, 7 and 8, all characterized by ultraviolet fluorescent cements, are capped by sub-aerial erosion surfaces. Unit 9 (the Holocene) reflects the recent re-establishment of marine conditions. The extent of alteration of the entire sequence reflects the substantial and pervasive influence of meteoric waters. This effect is interpreted as a result of a greater rainfall and river flow from the mainland during early and late stages of interstadial periods. The study reflects progress in the ability to recognize the diagenetic signal generated by sea-level change. However, whereas the isotopic results reflect the changing relationships between vadose and phreatic zones in groundwater systems beneath successive emergent surfaces, their correspondence with petrographic features is expressed only weakly and commonly lacks the systematic sequential overprinting implied by the distribution of cathodoluminescent zones of cements in many ancient limestones.