One of the most important steps in drilling and operation completion is oil well cementing to provide wellbore integrity. Cementing is usually performed in the oil industry using conventional Portland cement. Even though Portland cement has been used for many years, it has several drawbacks, including operational failures and severe environmental impacts. Fly ash based geopolymer cement has been recently investigated as a low-cost, environmentally friendly alternative to Portland cement. This research develops a novel formulation of Class C fly ash based geopolymer and investigates its applicability as an alternative to Portland cement in hydrocarbon well cementing. Twenty-four variations of fly ash Class C based geopolymers were prepared, and by comparing several of their properties using API standard tests, the optimum geopolymer formulation was determined. The ratios of alkaline activator to fly ash that were used are 0.2, 0.4, and 0.8, along with different ratios of sodium silicate to sodium hydroxide, including 0.25, 0.5, 1, and 2. Multiple sodium hydroxide concentrations were used, including 5, 10, and 15 molarity. The selection of the optimum formulation was based on five different tests, including rheology, density, compressive strength, fluid loss test, and stability tests (sedimentation test and free fluid test). Then, a comparison between the optimum mix design and Portland cement was conducted using the same tests. Based on our results, increasing sodium hydroxide concentration resulted in an increase in compressive strength and showed a slight decrease in the plastic viscosity. However, increasing in the alkaline activator to fly ash ratios increased plastic viscosity, and thus the pumpability of the slurry was reduced. Increasing the sodium silicate to sodium hydroxide ratio significantly decreased the fluid loss. The optimum design of geopolymer, which had lower fluid loss, 93 ml after 30 minutes, sufficient compressive strength, 1195 psi, and an acceptable density, 14.7 lb/gal, and viscosity, 50 cp, was selected. Compressive strength of the optimum design showed better results than neat Portland cement. Unlike neat Portland cement, which needs fluid loss additives, the new formulation of geopolymer investigated in this study showed fluid losses lower than 100 ml after 30 min when tested using a low-pressure, low-temperature filtrate loss tester. The higher mechanical strength of geopolymer using fly ash Class C compared to Portland cement is very promising for achieving long-term wellbore integrity goals and meeting regulatory criteria for zonal isolation. The rheological behavior, compressive strength, and fluid loss tests results indicate that fly ash Class C based geopolymer has the potential to be an environmentally friendly alternative to Portland cement when cementing oil wells.