Rare-earth (RE) oxyhydride thin films show a color-neutral, reversible photochromic effect at ambient conditions. The origin of the photochromism is the topic of current investigations. Here, we investigated the lattice defects, electronic structure, and crystal structure of photochromic YHxOy and GdHxOy thin films deposited by magnetron sputtering using positron annihilation techniques and X-ray diffraction, in comparison with Y, YH∼1.9, Y2O3, Gd, GdH∼1.8, and Gd2O3 films. Positron annihilation lifetime spectroscopy (PALS) reveals the presence of cation monovacancies in the as-deposited Y and YH∼1.9 films at concentrations of ∼10-5 per cation. In addition, vacancy clusters and nanopores are found in the as-prepared YHxOy and Y2O3 films. Doppler broadening positron annihilation spectroscopy (DB-PAS) of the Y- A nd Gd-based films reflects the transition from a metallic to an insulating nature of the RE metal, metal hydride, semiconducting oxyhydride and insulating oxide films. In-situ illumination DB-PAS shows the irreversible formation predominantly of di-vacancies, as PALS showed that cation mono-vacancies are already abundantly present in the as-prepared films. The formation of di-vacancies supports conjectures that H-(and/or O2-) ions become mobile upon illumination, as these will leave anion vacancies behind, some of which may subsequently cluster with cation vacancies present. In addition, in RE oxyhydride films, partially reversible shifts in the Doppler parameters are observed that correlate with the photochromic effect and point to the formation of metallic domains in the semiconducting films. Two processes are discussed that may explain the formation of these metallic domains and the changes in optical properties associated with the photochromic effect. The first process considers the reversible formation of metallic nanodomains with reduced O: H composition by transport of light-induced mobile hydrogen and local oxygen displacements. The second process considers metallic nanodomains resulting from the trapping of photoexcited electrons in an eg orbital at the yttrium ions surrounding positively charged hydrogen vacancies that are formed by light-induced removal of hydrogen atoms from octahedral sites. When a sufficiently large concentration, on the order of ∼10%, is reached in a certain domain of the film, band formation of the eg electrons may occur, leading to an Anderson-Mott insulator-metal transition like the case of yttrium trihydride in these domains.