The chemical constitution of tribofilms, generated from zinc dialkyldithiophosphate (ZDDP) and ashless dialkyldithiophosphate (DDP), has been examined by X-ray Absorption Near Edge Structure (XANES) spectroscopy. The identification of spectral features and interpretation of the results for P, O, Fe, and S species are given, allowing an overall mechanism to be deduced. The role of Fe in these films was investigated in some detail using P L-edge, O K-edge and Fe L-edge XANES spectra. From the P L-edge XANES spectra, the DDP films are uniformly very short chain iron polyphosphates. In contrast, the ZDDP films are formed initially as short chain polyphosphates; but after more rubbing, a bilayer phosphate film is formed with long chain Zn polyphosphates on the surface and shorter chain in the bulk of the film. The O K-edge XANES spectra show that there is, as expected, more Fe in the DDP phosphate films than in the ZDDP phosphate films. The S K-edge spectra of ZDDP films show the presence not only of ZnS as previously observed, but also the presence of FeS for the first time in the early stages of film formation. The predominant S species in the DDP films is FeS.