Tautomerism and protonation of guanine and cytosine in the gas phase and in aqueous solution have been examined by theoretical methods. High level ab initio calculations with inclusion of correlation effects at the Moller-Plesset level have been used to study these processes in the gas phase. The influence of solvent has been examined using self-consistent reaction field and Monte Carlo free energy perturbation simulations. The results provide a complete and accurate picture of tautomerism and protonation of these nucleic acid bases. Comparison with the available experimental data gives confidence in the quality of the results derived from theoretical computations. Inspection of the most stable tautomeric forms for the neutral and protonated nucleic acid bases allows rationalization of the formation of unusual DNA structures like the triple helix.