The atomic geometry and energetics of oxygen and potassium vacancies in potassium titanyl phosphate (KTP) as well as their electronic and optical properties are studied within density-functional theory in dependence of their charge state. Oxygen vacancies formed between Ti and P are characterized by a negative-U behavior. Their neutral charge state is favored for Fermi levels near the conduction band and gives rise to a defect level in the band gap, which leads to an additional optical absorption peak. In contrast, the two-fold positive charge state, stable for low and intermediate values of the Fermi level, modifies the KTP optical response only slightly. Oxygen vacancies formed between two Ti atoms are two-fold positively charged, while potassium vacancies are negatively charged irrespective of the Fermi level position. In both these cases, the KTP optical response is essentially not affected.