We investigate the interaction of Ti atoms with thin films made of 3,4,9,10 perylenetetracarboxylic dianhydride (PTCDA) molecules by means of self-consistent electronic structure calculations within a generalized gradient approximated density-functional theory framework. Following experimental suggestions, we model the thin films in terms of the bulk crystallographic structure of PTCDA. We fully optimize the atomic PTCDA structures in the presence of Ti impurities by local minimizations of the electronic total energy. We find that the Ti atoms react with the anhydride groups of PTCDA and form additional bridge-type bonds with the surrounding molecules. This process is accompanied by an electronic charge transfer from the metal atoms to the organic molecules, which provides a consistent interpretation of the experimentally observed C 1s core-level shifts upon metal deposition. As a consequence of the chemical reaction, electronic states are induced in the gap above the highest occupied molecular orbital level of the organic semiconductor, in good agreement with photoemisssion studies.