Nanocrystalline thin films of titanium nitride and titanium aluminium nitride were deposited on (111) Si substrates by reactive dc magnetron sputtering under various nitrogen flowrates and at constant substrate temperature. The effect of nitrogen flowrate on the structural and electrical properties of TiN x and Ti 12x Al x N thin films deposited at substrate temperatures of 973 and 773 K respectively is investigated. TiN x films are polycrystalline at all N 2 flowrates and there is a change of preferred orientation from (200) to (111) with increasing nitrogen flowrates. In contrast, Ti 12x Al x N thin films are polycrystalline only at low nitrogen flowrates (,5 sccm) and show a tendency to become more nanocrystalline with weak (200) preferred orientation at higher nitrogen flowrates. The variation of lattice parameter showed opposite behaviour in these two types of films. Auger electron spectroscopy indicated that the nitrogen concentration of both types of the films gradually increased with increasing nitrogen flowrate and almost reached a constant value at a flowrate of nitrogen >5 sccm. While the resistivity of TiN x films showed a minimum at a nitrogen flowrate of 5 sccm, the resistivity of Ti 12x Al x N films increased with increasing nitrogen flowrate. The variation in the electrical resistivity could be explained on the basis of structural changes occurring in these two types of films.