Compared with conventional semiconductors, the diluted magnetic semiconductors, in which the cations are substituted by transition metal ions, have attracted a great deal of attention due to their promising applications in spintronics. Recently, the unexpected room temperature ferromagnetism has been found in many undoped oxides. These findings challenge our understanding of magnetism in these systems, because neither cations nor anions have unpaired d or f electrons. Generally, the candidate defects responsible for the unexpected ferromagnetism must fulfill two conditions at the same time: (i) the defects should prefer a spin-polarized ground state with a nonzero local magnetic moments; (ii) the exchange interactions between local magnetic moments induced by defects should be ferromagnetic energetically. Among these oxides, TiO2 has recently attracted much attention because of its unique properties and potential applications in spintronics, laser diodes and biomaterials. In order to explore the origin of ferromagnetism in such an undoped TiO2 system, the electronic structures and magnetic properties of oxygen vacancy (VO) and Ti vacancy (VTi) in anatase TiO2 have been studied systematically by the first-principles calculation based on the density functional theory with the LDA+U method (UTi-3d = 5.8 eV). It is found that two electrons introduced by VO are captured by two neighbor Ti4+ ions, and thereby the Ti4+ ions are restored to Ti3+ ions with opposite spin orientation. Therefore, the single VO cannot induce local magnetic moment. The defect energy level locates near the Fermi level for VTi. Six oxygen atoms neighboring VTi constitute an octahedron, and the defect energy level is split into a single state A, a double state E and a triple state T in the octahedral crystal field. The occupation of four unpaired electrons introduced by six oxygen atoms is a+1t+3t-0e0 (subscripts + and - mean up-spin and down-spin, respectively), and the VTi can induce 4 B local moments. Furthermore, the magnetic coupling interaction between local magnetic moments induced by two VTi is ferromagnetic, and the magnetic coupling constant (JO) is 88.7 meV. It means the ferromagnetism can continue up to room-temperature. The VO cannot induce local magnetic moment, but it can enhance the coupling strength between two VTi, which can explain the origin of ferromagnetism observed experimentally in undoped anatase TiO2, i.e., the VTi induces local magnetic moment, while VO enhances the long range ferromagnetic coupling interaction between VTi. Especially, for the ferromagnetic coupling between local magnetic moments, we have proposed the second type direct exchange interaction model, which has been recommended in detail.