With rising energy demand and depleted traditional fuels, solar cells offer a sustainable and clean option. In recent years, and due to its acceptable band gap, high absorption coefficient, and inexpensive cost, iron pyrite (FeS2) is a popular material for solar cells. Earth abundance and nontoxicity further boost its photovoltaic possibilities. The current study examined the influence of sulfurization at 350–400 °C on iron pyrite layers fabricated using spray pyrolysis. The morphology and size from TEM confirmed the XRD results of synthesizing a pyrite FeS2 with an average particle size of 10–23 nm at 350–400 °C, respectively. The direct band gap calculated by DFT as a function of temperature was found to be consistent with the experimental findings, 0.87 eV (0.87) and 0.90 eV (0.95) at 350 °C and 400 °C, respectively. We found high-performing photovoltaic cells on ITO/ZnO/FeS2/ MoO3/Au/Ag, obtained with an excellent quality of nanoparticles and nanostructures of FeS2 pyrite, which improved with the method of preparation and growth parameters.