Nanocrystalline mesoporous N-doped titania films have been prepared for the first time. The introduction of nitrogen into the anatase structure starts at 500 °C, with N bonding to titanium via oxygen substitution. Increasing the treatment temperature leads to the formation of TiN (TiN1-xO x) and N-doped rutile showing mixed-valence Ti states. Microstructural characterization shows that the ordered mesoporosity is maintained until 700 °C, where TiN (TiN1-xOx) begins to form. Optical characterization shows that the discrete introduction of N is able to shift the titania absorption edge. The photocatalytic tests give the best results under visible light excitation for the film nitrided at 500 °C. At this temperature the concentration of nitrogen in the structure is optimal since oxygen vacancies are still not important enough to promote the recombination of the photogenerated electrons and holes. © 2007 WILEY-VCH Verlag GmbH & Co. KCaA,.