  The electronic and magnetic properties of TiO$_2$, TiO$_{1.75}$,
TiO$_{1.75}$N$_{0.25}$, and TiO$_{1.75}$F$_{0.25}$ compounds have been studied
by using \emph{ab initio} electronic structure calculations. TiO$_2$ is found
to evolve from a wide-band-gap semiconductor to a narrow-band-gap semiconductor
to a half-metallic state and finally to a metallic state with oxygen vacancy,
N-doping and F-doping, respectively. Present work clearly shows the robust
magnetic ground state for N- and F-doped TiO$_2$. The N-doping gives rise to
magnetic moment of $\sim$0.4 $\mu_B$ at N-site and $\sim$0.1 $\mu_B$ each at
two neighboring O-sites, whereas F-doping creates a magnetic moment of
$\sim$0.3 $\mu_B$ at the nearest Ti atom. Here we also discuss the possible
cause of the observed magnetic states in terms of the spatial electronic charge
distribution of Ti, N and F atoms responsible for bond formation.
