The mechanism of surface modification of titania by calcination with urea at 400 degrees C was investigated by substituting urea by its thermal decomposition products. It was found that during the urea-induced process titania acts as a thermal catalyst for the conversion of intermediate isocyanic acid to cyanamide. Trimerization of the latter produces melamine followed by polycondensation to melem- and melon-based poly(aminotri-s-triazine) derivatives. Subsequently, amino groups of the latter finish the process by formation of Ti--N bonds through condensation with the OH-terminated titania surface. When the density of these groups is too low, like in substoichiometric titania, no corresponding modification occurs. The mechanistic role of the polytriazine component depends on its concentration. If present in only a small amount, it acts as a molecular photosensitizer. At higher amounts it forms a crystalline semiconducting organic layer, chemically bound to titania. In this case the system represents a unique example of a covalently coupled inorganic-organic semiconductor photocatalyst. Both types of material exhibit the quasi-Fermi level of electrons slightly anodically shifted relative to that of titania. They are all active in the visible-light mineralization of formic acid, whereas nitrogen-modified titania prepared from ammonia is inactive.