Sol–gel SiO2 antireflective coatings were prepared with different post-treatments, and their performance in a vacuum environment with intentionally induced organic contaminants were studied in detail. The pores of the silica coating can be filled with contaminants, which can increase the refractive index of the film and also absorb or scatter the light and therefore reduce the transmittance. Heat treatment at low temperature can insure against the possible volatilization of the components of the coating, but does not prevent the adsorption of organic contaminants and the degeneration of the transmittance. If an ammonia and hexamethyldisilazane (HMDS) vapor treatment is adopted before heat treatment, the optical stability can be greatly enhanced by reducing the adsorption of contaminants. The increased resistance to contamination is due to changes in the coating’s structure and composition, including a reduction of the specific surface area and surface polarity as a result of ammonia treatment and HMDS treatment, respectively.