A highly selective optical sensor for Fe (II) ions was developed based on entrapment of a sensitive reagent, 2,4,6-tri(2-pyridyl)-s-triazine (TPTZ), in a silica sol–gel thin film coated on a glass substrate. The thin films fabricated based on tetraethoxysilane (TEOS) as precursor, sol–gel pH 3, water:alkoxyde ratio of 4:1 and TPTZ concentration of 0.112 mol L1. The influence of sol–gel parameters on sensing behavior of the fabricated sensor was also investigated. The fabricated sensor can be used for determination of Fe (II) ion with an outstanding high selectivity over a dynamic range of 5–115 ng mL1 and a detection limit of 1.68 ng mL1. It also showed reproducible results with relative standard deviation of 3.5% and 1.27% for 10 and 90 ng mL1 of Fe (II), respectively, along with a fast response time of 120 s. Total iron also was determined after reduction of Fe (III) to Fe (II) using ascorbic acid as reducing agent. Then, the concentration of Fe (III) was calculated by subtracting the concentration of Fe (II) from the total iron concentration. Interference studies showed a good selectivity for Fe (II) with trapping TPTZ into sol–gel matrix and appropriately adjusting the structure of doped sol–gel. The sensor was compared with other sensors and was applied to determine iron in different water samples with good results.