Ab initio surface hopping dynamics calculations were performed to study the photophysical behavior of cytosine and guanine embedded in DNA using a quantum mechanical/molecular mechanics (QM/MM) approach. It was found that the decay rates of photo excited cytosine and guanine were affected in a completely different way by the hydrogen bonding to the DNA environment. In case of cytosine, the geometrical restrictions exerted by the hydrogen bonds did not influence the relaxation time of cytosine significantly due to the generally small cytosine ring puckering required to access the crossing region between excited and ground state. On the contrary, the presence of hydrogen bonds significantly altered the photodynamics of guanine. The analysis of the dynamics indicates that the major contribution to the lifetime changes comes from the interstrand hydrogen bonds. These bonds considerably restricted the out-of-plane motions of the NH(2) group of guanine which are necessary for the ultrafast decay to the ground state. As a result, only a negligible amount of trajectories decayed into the ground state for guanine embedded in DNA within the simulation time of 0.5 ps, while for comparison, the isolated guanine relaxed to the ground state with a lifetime of about 0.22 ps. These examples show that, in addition to phenomena related to electronic interactions between nucleobases, there also exist relatively simple mechanisms in DNA by which the lifetime of a nucleobase is significantly enhanced as compared to the gas phase.