The western Sichuan Basin located at the front of the Longmen Mountain in the western Sichuan Province of China is a foreland basin formed in the Late Triassic. The Upper Triassic Xujiahe Formation in the basin is an ultralow-permeability and low-porosity tight-gas sandstone reservoir. Microfractures, such as intragranular microfractures, grain-edge microfractures, and transgranular microfractures, are abundant in the tight sandstones. Microfractures improve storage and permeability and impact distribution of natural gas. Microfractures reflect tectonic, overpressure, and diagenetic origins. Using quartz and calcite fluid inclusions and burial history, tectonic microfractures were determined to be formed at the end of the Triassic, the end of the Cretaceous, and the end of the Neogene–early Pleistocene. Microfractures related to overpressure, being tension microfractures, are commonly filled with bitumen and were formed at the middle to Late Cretaceous when the maximum pressure coefficients were 1.6 to 2.1. In the middle to late Neogene, the pressure coefficient was reduced to less than 1.3 because of fault activity and tectonic uplift in the southwestern Sichuan Basin, and these tension microfractures closed and were filled with calcite. The transition of stress state from compression to tension by overpressure is the reason that tension microfractures were formed in the compression setting. Diagenetic fractures were formed at the end of the Late Triassic to Jurassic. Under intense compaction, grain-crushing crackle fractures in quartz and cleavage fractures in feldspar formed intragranular microfractures. Some transgranular microfractures caused by diagenesis are along the bedding plane and parallel to the directional mineral grains.