The stability of quantum systems to perturbations of the Hamiltonian is studied. This stability is quantified by the fidelity. Dependence of fidelity on the initial state as well as on the dynamical properties of the system is considered. In particular, systems having a chaotic or regular classical limit are analysed. The fidelity decay rate is given by an integral of the correlation function of the perturbation and is thus smaller the faster correlation function decays. If the perturbation can be written as a time derivative of another operator, meaning that the time averaged perturbation vanishes, fidelity freezes at a constant value and starts to decay only after a long time inversely proportional to the perturbation strength. In composite systems stability of entanglement to perturbations of the Hamiltonian is analysed in terms of purity. For regular systems purity decay is shown to be independent of Planck's constant for coherent initial states in the semiclassical limit. The accelerated decoherence of macroscopic superpositions is also explained. The theory of fidelity decay is applied to the stability of quantum computation and an improved quantum Fourier transform algorithm is designed.