The deep high-temperature, high-pressure Lower Cretaceous Bashijiqike sandstone (buried to depths as great as 6.5–7.1 km [21,325–23,293 ft]) is an important natural gas reservoir in Keshen gas field, Kuqa depression of the Tarim basin. Reservoir quality is a critical risk factor in the development of these ultradeep reservoirs. Integrated approaches incorporating routine core analyses and mineralogical, petrographic, and geochemical analyses have been used to investigate the diagenetic history of these rocks and their effect on reservoir quality with the aim to unravel the mechanisms for maintaining anomalously high porosities in sandstones that are buried to such a great depth. These sandstones are dominantly fine- to medium-grained, moderately to well-sorted lithic arkoses and feldspathic litharenite. Most primary pores have been lost by mechanical compaction or carbonate cementation, and the reduction of porosity by mechanical compaction was more significant than that by cementation. Dissolution of framework grains contributed to the enhancement of reservoir quality. Eogenetic diagenetic alterations mainly include mechanical compaction, precipitation of calcite cements, and grain-coating clays, and mesogenetic diagenesis is characterized by dissolution of framework grain by organic acids and subsequent precipitation of clay minerals and quartz. Infiltration of meteoric water related to teleodiagenesis would result in dissolution of the framework grains. The meteoric leaching events during teleodiagenesis are of great importance for the Bashijiqike sandstones. Grain-coating clay minerals (mixed-layer illite/smectite clays) help to preserve porosity at depth by retarding quartz cementation and pressure solution. The unique burial regime as early-stage shallow burial with late-stage rapid deep burial contributes to porosity preservation in eodiagenesis. Fluid overpressure caused by intense structural compression in the middle Himalayan movement retarded compaction and helped preserve porosity in the late rapid deep burial stage. Anomalously high porosities are mainly found in medium-grained, well-sorted sandstones with grain-coating clays but with low clay and carbonate cement content, of which the porosity is preserved primarily and enhanced secondarily. The lowest porosities are associated with sandstones that are tightly compacted or cemented with carbonates or rich in detrital matrix. Porosity–depth trends may vary significantly with lithofacies because of their differences in textural and compositional attributes. Five lithofacies are defined in terms of detrital composition and texture and type and degree of diagenesis. The reservoir quality prediction models of various litho-facies are constructed, and the results of this study provide insights into mechanisms for maintaining anomalously high porosity and permeability in high-temperature, high-pressure sandstone reservoirs and may help explain hydrocarbon distribution.