Significant amounts of hydrocarbon resources are left behind after primary and secondary recovery processes, necessitating the application of enhanced oil recovery (EOR) techniques for improving the recovery of trapped oil from subsurface formations. In this respect, the wettability of the rock is crucial in assessing the recovery and sweep efficiency of trapped oil. The subsurface reservoirs are inherently contaminated with organic acids, which renders them hydrophobic. Recent research has revealed the significant impacts of nanofluids, surfactants, and methyl orange on altering the wettability of organic-acid-contaminated subsurface formations into the water-wet state. This suggests that the toxic dye methylene blue (MB), which is presently disposed of in huge quantities and contaminates subsurface waters, could be used in EOR. However, the mechanisms behind hydrocarbon recovery using MB solution for attaining hydrophilic conditions are not fully understood. Therefore, the present work examines the impacts of MB on the wettability reversal of organic-acid-contaminated Khewra sandstone samples (obtained from the outcrop in the Potwar Basin, Pakistan) under the downhole temperature and pressure conditions. The sandstone samples are prepared by aging with 10-2 mol/L stearic acid and subsequently treated with various amounts of aqueous MB (10-100 mg/L) for 1 week. Contact angle measurements are then conducted under various physio-thermal conditions (0.1-20 MPa, 25-50 °C, and salinities of 0.1-0.3 M). The results indicate that the Khewra sandstone samples become hydrophobic in the presence of organic acid and under increased pressure, temperature, and salinity. However, the wettability changes from oil-wet to preferentially water-wet in the presence of various MB solutions, thus highlighting the favorable effects of MB on EOR from the Khewra sandstone formation. Moreover, the most significant change in wettability is observed for the Khewra sandstone sample that was aged using 100 mg/L MB. These results suggest that injecting MB into deep underground Khewra sandstone reservoirs may produce more residual hydrocarbons.