Summary Knowing the composition, molecular size, and structure of polar compounds in crude oil that affect sandstone wettability is a prerequisite for a better understanding of oil/rock/brine interactions and for better application of enhanced oil recovery (EOR) techniques to increase recovery factors and improve the economic efficiency of field development. The nitrogen-, sulfur-, and oxygen-containing polar compounds in crude oil are key factors for sandstone wettability changes. In this study, an outcrop sandstone core selected from Jurassic formation in Sichuan Basin, China, was aged by crude oil to restore the wettability after being cleaned by hot Soxhlet extraction with an azeotropic solvent mixture of methanol and dichloromethane (MDC, vol/vol = 7:93). Then, Amott-Harvey experiments that were conducted by combining spontaneous imbibition and forced displacement steps of coreflooding were performed to characterize sandstone wettability after it was cut into four core blocks. The wettability index (IA-H) of four core blocks from the inlet to outlet of oil flooding were −0.523, 0.214, −0.087, and −0.861, respectively, which illustrated different degrees of sandstone wettability. The extracts of three sequential hot Soxhlet extraction steps of four core blocks were analyzed by gas chromatography-mass spectrometry (GC-MS) and high-resolution Fourier transform-ion cyclotron resonance-mass spectrometry (FT-ICR-MS) combined with electrospray ionization (ESI) in negative ion mode. Almost no polar compounds were detected in the n-hexane extracts, and a total of seven classes of different polar molecular compounds—namely, N1, N1O1, N1S1, O1, O2, O3, and O4—were detected in dichloromethane (DCM) and MDC extracts. The relative abundances of the N1S1 and O1 classes in the extracts of DCM and MDC were too low to be ignored. Compared to those of polar compounds in DCM extracts, the relative abundance of neutral nitrogen compounds (N1 and N1O1 classes) in the MDC extracts decreased significantly. In contrast, the acidic compounds (O2, O3, and O4 classes) all showed an obvious increase in the MDC extracts compared to the DCM extracts. It was notable that most of the polar compounds in MDC extracts were O2 and O3 compounds with double bond equivalent (DBE) values = 1 from the perspective of DBE distribution. The proportion of these two compound classes was much higher than that of all other polar compounds. Therefore, we believe that these two compound classes are the decisive factors for changing sandstone wettability combined with previous studies. In addition, based on the number of oxygen atoms and DBE values, we inferred that the O2 (DBE = 1) class was the long-chain saturated fatty acids and that the O3 (DBE = 1) class was the hydroxyl acids containing both one carboxyl and one hydroxyl group. Furthermore, the final determination of the wettability degree of the sandstone surface was the amount of all polar compounds, not only the relative abundance of these two types of acids. These two types of acids in crude oil were equivalent to anchor molecules on the surface of sandstone, and other polar compounds were adsorbed onto their surface to make the sandstone preferentially oil-wet.