Summary Viscoelasticity plays a significant role in improving the performance of the drilling fluid by manipulating its elastic properties. An appropriate value of the first normal stress difference (N1), extensional viscosity (ηe), and relaxation time (θ) enhance the cutting transportability, hole-cleaning ability, filtration loss, and lubrication behavior. However, the performance of the drilling fluid deteriorates during the drilling of high-pressure and high-temperature (HPHT) wells under acid gas and salt(s) contamination. Therefore, it is a challenging task to synthesize a thermally and rheologically stable drilling fluid, which is acid as well as salt(s) resistant, and maintain its desired properties. Although several water-soluble synthetic polymer-based drilling fluids have been used widely for the drilling of HPHT wells, most of these are limited at less than 200°C. Polyanionic cellulose (PAC) has an excellent heat-resistant stability, salt tolerance, calcium and magnesium resistant, and strong antibacterial activity, and it exhibits exceptional filtration and rheological behavior under HPHT conditions. However, using PAC beyond 200°C is limited because of the presence of the biodegradable cellulose units in it. To use the extraordinary properties of PAC, it is aimed to increase the thermal stability of PAC through appropriate modification. In this study, PAC-grafted copolymers involving acrylamide (a salt-tolerant viscosifying agent), 2-acrylamide-2-methyl-1-propane sulfonic acid (a thermally stable lubricating and fluid-loss control agent), and sodium 4-styrene sulfonate (a high-temperature deflocculant) is synthesized optimally through maximizing the thermal degradation stability of the grafted copolymer and minimizing the filtration loss as well as the coefficient of friction (CoF) of the drilling fluid simultaneously. Optimally synthesized PAC-grafted copolymers are then used to prepare water-based mud (WBM) involving American Petroleum Institute (API)-grade bentonite and alpha-glycol functionalized nano fly ash, and the tests for steady shear viscosity and viscoelasticity are performed to determine the rheological stability of mud beyond 200°C. The amplitude sweep tests for viscoelasticity are performed to determine the linear viscoelasticity range (LVR), structural stability, gel strength, and dynamic yield point (YP), whereas frequency, time, and temperature sweep tests are performed to obtain the elastic modulus (G′), viscous modulus (G″), and complex viscosity under HPHT conditions to check the stability of the drilling fluids under different holding times. Dynamic and static aging tests of the developed drilling fluids are performed at elevated temperature and pressure, and the aged muds are tested by evaluating the rheology, frictional, and filtration-loss behavior as per the API recommended procedure. The stability of the aged muds is also tested by evaluating the N1, ηe, and θ using a cone and plate rheometer. The performance of the proposed drilling fluids is also tested under acidic, sodium chloride (NaCl), and calcium chloride (CaCl2) environments at HPHT bottomhole conditions. The experimental results under HPHT conditions reveal that the performance of the mud (i.e., thermal stability, cutting transportability, hole-cleaning ability, filtration loss, and lubrication behavior) could be considerably improved by increasing the elastic properties of the drilling fluid by manipulating the molecular weight of the proposed PAC-grafted copolymer. Finally, the environmental effect of the developed muds is evaluated by finding the lethal concentration that kills 50% of the shrimp population (i.e., LC50) and the Hg and Cd contamination, and they are found to be environmentally safe.